some progress
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user