Files
ismysiteup.online/app/Console/Commands/MonitorSitemaps.php
T

57 lines
1.3 KiB
PHP
Raw Normal View History

2026-01-24 12:16:10 +02:00
<?php
namespace App\Console\Commands;
use App\Jobs\CheckSitemap;
use App\Models\Sitemap;
use Illuminate\Console\Command;
class MonitorSitemaps extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'monitor:sitemaps';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Check all active sitemaps for validity and accessibility';
/**
* Execute the console command.
*/
public function handle()
{
$this->info('Starting sitemap monitoring...');
$sitemaps = Sitemap::where('is_active', true)->get();
if ($sitemaps->isEmpty()) {
$this->warn('No active sitemaps found to monitor.');
return Command::SUCCESS;
}
$this->info("Found {$sitemaps->count()} active sitemap(s) to check.");
$progressBar = $this->output->createProgressBar($sitemaps->count());
$progressBar->start();
foreach ($sitemaps as $sitemap) {
CheckSitemap::dispatch($sitemap);
$progressBar->advance();
}
$progressBar->finish();
$this->newLine();
$this->info('Sitemap check jobs have been dispatched.');
return Command::SUCCESS;
}
}