57 lines
1.3 KiB
PHP
57 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Jobs\CheckDomainExpiry;
|
|
use App\Models\Domain;
|
|
use Illuminate\Console\Command;
|
|
|
|
class MonitorDomains extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'monitor:domains';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Check expiry dates for all active domains';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*/
|
|
public function handle()
|
|
{
|
|
$this->info('Starting domain expiry monitoring...');
|
|
|
|
$domains = Domain::where('is_active', true)->get();
|
|
|
|
if ($domains->isEmpty()) {
|
|
$this->warn('No active domains found to monitor.');
|
|
return Command::SUCCESS;
|
|
}
|
|
|
|
$this->info("Found {$domains->count()} active domain(s) to check.");
|
|
|
|
$progressBar = $this->output->createProgressBar($domains->count());
|
|
$progressBar->start();
|
|
|
|
foreach ($domains as $domain) {
|
|
CheckDomainExpiry::dispatch($domain);
|
|
$progressBar->advance();
|
|
}
|
|
|
|
$progressBar->finish();
|
|
$this->newLine();
|
|
|
|
$this->info('Domain expiry check jobs have been dispatched.');
|
|
|
|
return Command::SUCCESS;
|
|
}
|
|
}
|