public function sitemap()
    {
        $base = rtrim(config('app.url'), '/');

        $stream = function () use ($base) {
            $writeUrl = function (string $loc, ?string $lastmod = null, string $freq = 'weekly', string $prio = '0.8') {
                $last = $lastmod ?: now()->toAtomString();
                echo "  <url>\n";
                echo "    <loc>" . e($loc) . "</loc>\n";
                echo "    <lastmod>{$last}</lastmod>\n";
                echo "    <changefreq>{$freq}</changefreq>\n";
                echo "    <priority>{$prio}</priority>\n";
                echo "  </url>\n";
            };

            // XML header + open tag
            echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
            echo "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";

            // --- Static pages (by route names you listed)
            $static = [
                'home','services/private-trip','destinations','blogs','quotation','contact','privacy-policy','FAQ',
            ];
            foreach ($static as $name) {
                if (Route::has($name)) {
                    $writeUrl($base . route($name, [], false));
                }
            }

            // --- Blogs (slug)
            Blog::query()
                ->select(['slug','updated_at','created_at'])
                // ->where('is_active', 1) // adjust to your scope/column
                ->orderByDesc('updated_at')
                ->chunk(1000, function ($chunk) use ($writeUrl, $base) {
                    foreach ($chunk as $b) {
                        $url = $base . route('blogs.show', ['slug' => $b->slug], false);
                        $writeUrl($url, optional($b->updated_at ?? $b->created_at)->toAtomString(), 'weekly', '0.9');
                    }
                });

            // --- Works (slug or id bound to {work})
            

            // Close tag
            echo "</urlset>\n";
        };
        return response()->stream($stream, 200, [
            'Content-Type' => 'application/xml; charset=UTF-8',
            'X-Robots-Tag' => 'noindex, follow', // change to 'index, follow' after you’re happy
        ]);
        
       
    }