27 lines
796 B
PHP
27 lines
796 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Services\Payments\PaymentMissedCheckService;
|
|
use Illuminate\Console\Command;
|
|
|
|
class CheckMissedPaymentsCommand extends Command
|
|
{
|
|
protected $signature = 'payments:check-missed';
|
|
protected $description = 'Checks for users who missed payments and sends reminders.';
|
|
|
|
public function handle(PaymentMissedCheckService $service): int
|
|
{
|
|
$users = $service->findUsersWithMissedPayments();
|
|
if (empty($users)) {
|
|
$this->info('No missed payments found.');
|
|
return self::SUCCESS;
|
|
}
|
|
|
|
$result = $service->sendReminders($users);
|
|
$this->info(sprintf('Finished checking missed payments. Sent: %d, Failed: %d.', $result['sent'], $result['failed']));
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
}
|