<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Cache;

class RefreshSitemapCommand extends Command
{
    /**
     * The name and signature of the console command.
     */
    protected $signature = 'sitemap:refresh';

    /**
     * The console command description.
     */
    protected $description = 'Clear the cached sitemap so it is regenerated on the next request';

    /**
     * Execute the console command.
     */
    public function handle(): int
    {
        Cache::forget('sitemap.urls');

        $this->info('Sitemap cache cleared. It will be regenerated on the next request to /sitemap.xml');

        return self::SUCCESS;
    }
}
