From 9099bdc1056ebaf886c15f4182b257cc90235772 Mon Sep 17 00:00:00 2001 From: A1Gard Date: Tue, 15 Oct 2024 05:14:10 +0330 Subject: [PATCH] fixed sitemap bug --- app/Http/Controllers/ClientController.php | 54 +++++++++++++++-------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/app/Http/Controllers/ClientController.php b/app/Http/Controllers/ClientController.php index 9615ae6..7b94af6 100644 --- a/app/Http/Controllers/ClientController.php +++ b/app/Http/Controllers/ClientController.php @@ -642,39 +642,57 @@ class ClientController extends Controller public function sitemap() { - header('content-type: text/xml'); - echo ''.PHP_EOL; - return view('website.sitemaps.sitemap'); + $xmlContent = '' . PHP_EOL; + $xmlContent .= view('website.sitemaps.sitemap')->render(); // Render the view and append to XML content + + // Return the XML response + return response($xmlContent, 200) + ->header('Content-Type', 'text/xml'); } public function sitemapPosts() { - header('content-type: text/xml'); - echo ''.PHP_EOL; - return view('website.sitemaps.sitemap-posts'); + $xmlContent = '' . PHP_EOL; + $xmlContent .= view('website.sitemaps.sitemap-posts')->render(); // Render the view and append to XML content + + // Return the XML response + return response($xmlContent, 200) + ->header('Content-Type', 'text/xml'); } public function sitemapProducts() { - header('content-type: text/xml'); - echo ''.PHP_EOL; - return view('website.sitemaps.sitemap-products'); + $xmlContent = '' . PHP_EOL; + $xmlContent .= view('website.sitemaps.sitemap-products')->render(); // Render the view and append to XML content + + // Return the XML response + return response($xmlContent, 200) + ->header('Content-Type', 'text/xml'); } public function sitemapClips() { - header('content-type: text/xml'); - echo ''.PHP_EOL; - return view('website.sitemaps.sitemap-clips'); + $xmlContent = '' . PHP_EOL; + $xmlContent .= view('website.sitemaps.sitemap-clips')->render(); // Render the view and append to XML content + + // Return the XML response + return response($xmlContent, 200) + ->header('Content-Type', 'text/xml'); } public function sitemapGalleries() { - header('content-type: text/xml'); - echo ''.PHP_EOL; - return view('website.sitemaps.sitemap-gallries'); + $xmlContent = '' . PHP_EOL; + $xmlContent .= view('website.sitemaps.sitemap-gallries')->render(); // Render the view and append to XML content + + // Return the XML response + return response($xmlContent, 200) + ->header('Content-Type', 'text/xml'); } public function sitemapAttachments() { - header('content-type: text/xml'); - echo ''.PHP_EOL; - return view('website.sitemaps.sitemap-attachments'); + $xmlContent = '' . PHP_EOL; + $xmlContent .= view('website.sitemaps.sitemap-attachments')->render(); // Render the view and append to XML content + + // Return the XML response + return response($xmlContent, 200) + ->header('Content-Type', 'text/xml'); } public function lang(Request $request)