Files
thankcard-system/app/Console/Commands/ResetCardsCommand.php
T
2026-08-01 14:40:04 +07:00

34 lines
958 B
PHP

<?php
namespace App\Console\Commands;
use App\Services\Admin\Contracts\AdminServiceInterface;
use Illuminate\Console\Command;
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();
$this->info('Successfully reset all cards for active members to 0!');
} catch (\Throwable $e) {
\Illuminate\Support\Facades\Log::error('Lỗi xảy ra khi chạy command reset thẻ hàng tháng (cards:reset): ' . $e->getMessage());
$this->error('Reset cards failed: ' . $e->getMessage());
return Command::FAILURE;
}
return Command::SUCCESS;
}
}