Files
thankcard-system/app/Console/Commands/ResetCardsCommand.php
T
2026-08-01 22:54:56 +07:00

34 lines
894 B
PHP

<?php
namespace App\Console\Commands;
use App\Services\Admin\Contracts\AdminServiceInterface;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
class ResetCardsCommand extends Command
{
protected $signature = 'cards:reset';
protected $description = 'Reset all system cards to 0 at the beginning of the month';
public function __construct(
private AdminServiceInterface $adminService
) {
parent::__construct();
}
public function handle()
{
try {
$this->adminService->resetAllCards();
Log::info('Successfully reset all cards for active members to 0!');
} catch (\Throwable $e) {
Log::error('Error occurred while executing monthly card reset command (cards:reset): ' . $e->getMessage());
return Command::FAILURE;
}
return Command::SUCCESS;
}
}