From ed4d58bd4d0376969c88e47ee089eadb476d64d4 Mon Sep 17 00:00:00 2001 From: A1Gard Date: Tue, 15 Oct 2024 05:05:09 +0330 Subject: [PATCH] improved sitemap --- app/Http/Controllers/ClientController.php | 33 ++- .../views/website/inc/website-head.blade.php | 2 + resources/views/website/sitemap.blade.php | 192 ------------------ .../sitemaps/sitemap-attachments.blade.php | 50 +++++ .../website/sitemaps/sitemap-clips.blade.php | 48 +++++ .../sitemaps/sitemap-gallries.blade.php | 50 +++++ .../website/sitemaps/sitemap-posts.blade.php | 50 +++++ .../sitemaps/sitemap-products.blade.php | 50 +++++ .../views/website/sitemaps/sitemap.blade.php | 50 +++++ routes/web.php | 5 + 10 files changed, 337 insertions(+), 193 deletions(-) delete mode 100644 resources/views/website/sitemap.blade.php create mode 100644 resources/views/website/sitemaps/sitemap-attachments.blade.php create mode 100644 resources/views/website/sitemaps/sitemap-clips.blade.php create mode 100644 resources/views/website/sitemaps/sitemap-gallries.blade.php create mode 100644 resources/views/website/sitemaps/sitemap-posts.blade.php create mode 100644 resources/views/website/sitemaps/sitemap-products.blade.php create mode 100644 resources/views/website/sitemaps/sitemap.blade.php diff --git a/app/Http/Controllers/ClientController.php b/app/Http/Controllers/ClientController.php index 9e74dc0..9615ae6 100644 --- a/app/Http/Controllers/ClientController.php +++ b/app/Http/Controllers/ClientController.php @@ -643,7 +643,38 @@ class ClientController extends Controller public function sitemap() { header('content-type: text/xml'); - return view('website.sitemap'); + echo ''.PHP_EOL; + return view('website.sitemaps.sitemap'); + } + public function sitemapPosts() + { + header('content-type: text/xml'); + echo ''.PHP_EOL; + return view('website.sitemaps.sitemap-posts'); + } + public function sitemapProducts() + { + header('content-type: text/xml'); + echo ''.PHP_EOL; + return view('website.sitemaps.sitemap-products'); + } + public function sitemapClips() + { + header('content-type: text/xml'); + echo ''.PHP_EOL; + return view('website.sitemaps.sitemap-clips'); + } + public function sitemapGalleries() + { + header('content-type: text/xml'); + echo ''.PHP_EOL; + return view('website.sitemaps.sitemap-gallries'); + } + public function sitemapAttachments() + { + header('content-type: text/xml'); + echo ''.PHP_EOL; + return view('website.sitemaps.sitemap-attachments'); } public function lang(Request $request) diff --git a/resources/views/website/inc/website-head.blade.php b/resources/views/website/inc/website-head.blade.php index dcaa0f9..376f6f2 100644 --- a/resources/views/website/inc/website-head.blade.php +++ b/resources/views/website/inc/website-head.blade.php @@ -8,6 +8,8 @@ @if(! config('app.demo')) + @else + @endif diff --git a/resources/views/website/sitemap.blade.php b/resources/views/website/sitemap.blade.php deleted file mode 100644 index 57bb88e..0000000 --- a/resources/views/website/sitemap.blade.php +++ /dev/null @@ -1,192 +0,0 @@ - - - - @if(\App\Models\Product::count() > 0) - - - {{route('client.products')}} - {{\App\Models\Product::orderByDesc('updated_at')->first()->updated_at->tz('UTC')->toAtomString()}} - daily - 1 - - @endif - @if(\App\Models\Post::count() > 0) - - - {{route('client.posts')}} - {{\App\Models\Post::orderByDesc('updated_at')->first()->updated_at->tz('UTC')->toAtomString()}} - weekly - 1 - - @endif - @if(\App\Models\Gallery::count() > 0) - - - {{route('client.galleries')}} - {{\App\Models\Gallery::orderByDesc('updated_at')->first()->updated_at->tz('UTC')->toAtomString()}} - weekly - 2 - - @endif - @if(\App\Models\Attachment::count() > 0) - - - {{route('client.attachments')}} - {{\App\Models\Attachment::orderByDesc('updated_at')->first()->updated_at->tz('UTC')->toAtomString()}} - weekly - 2 - - @endif - @if(\App\Models\Clip::count() > 0) - - - {{route('client.clips')}} - {{\App\Models\Clip::orderByDesc('updated_at')->first()->updated_at->tz('UTC')->toAtomString()}} - weekly - 2 - - @endif - @foreach(\App\Models\Product::where('status',1)->orderBy('id')->get(['slug','updated_at']) as $item) - - - {{route('client.product',$item->slug)}} - {{$item->updated_at->tz('UTC')->toAtomString()}} - weekly - 3 - - @endforeach - @foreach(\App\Models\Post::where('status',1)->orderBy('id')->get(['slug','updated_at']) as $item) - - - {{route('client.post',$item->slug)}} - {{$item->updated_at->tz('UTC')->toAtomString()}} - weekly - 3 - - @endforeach - @foreach(\App\Models\Clip::where('status',1)->orderBy('id')->get(['slug','updated_at']) as $item) - - - {{route('client.clip',$item->slug)}} - {{$item->updated_at->tz('UTC')->toAtomString()}} - weekly - 3 - - @endforeach - @foreach(\App\Models\Gallery::where('status',1)->orderBy('id')->get(['slug','updated_at']) as $item) - - - {{route('client.gallery',$item->slug)}} - {{$item->updated_at->tz('UTC')->toAtomString()}} - weekly - 3 - - @endforeach - @foreach(\App\Models\Attachment::where('is_fillable',1)->orderBy('id')->get(['slug','updated_at']) as $item) - - - {{route('client.attachment',$item->slug)}} - {{$item->updated_at->tz('UTC')->toAtomString()}} - weekly - 3 - - @endforeach - @if(config('app.xlang.active')) - @foreach(\App\Models\XLang::where('is_default',0)->pluck('tag')->toArray() as $lang) - - @php(app()->setLocale($lang)) - @if(\App\Models\Product::count() > 0) - - - {{route('client.products')}}/{{$lang}} - {{\App\Models\Product::orderByDesc('updated_at')->first()->updated_at->tz('UTC')->toAtomString()}} - daily - 1 - - @endif - @if(\App\Models\Post::count() > 0) - - - {{route('client.posts')}}/{{$lang}} - {{\App\Models\Post::orderByDesc('updated_at')->first()->updated_at->tz('UTC')->toAtomString()}} - weekly - 1 - - - @endif - @if(\App\Models\Gallery::count() > 0) - - - {{route('client.galleries')}}/{{$lang}} - {{\App\Models\Gallery::orderByDesc('updated_at')->first()->updated_at->tz('UTC')->toAtomString()}} - weekly - 2 - - @endif - @if(\App\Models\Attachment::count() > 0) - - - {{route('client.attachments')}}/{{$lang}} - {{\App\Models\Attachment::orderByDesc('updated_at')->first()->updated_at->tz('UTC')->toAtomString()}} - weekly - 2 - - @endif - @if(\App\Models\Clip::count() > 0) - - - {{route('client.clips')}}/{{$lang}} - {{\App\Models\Clip::orderByDesc('updated_at')->first()->updated_at->tz('UTC')->toAtomString()}} - weekly - 2 - - @endif - @foreach(\App\Models\Product::where('status',1)->whereLocale('name',$lang)->orderBy('id')->get(['slug','updated_at','name']) as $item) - - - {{$item->webUrl()}} - {{$item->updated_at->tz('UTC')->toAtomString()}} - weekly - 3 - - @endforeach - @foreach(\App\Models\Post::where('status',1)->whereLocale('title',$lang)->orderBy('id')->get(['slug','updated_at','title']) as $item) - - - {{$item->webUrl()}} - {{$item->updated_at->tz('UTC')->toAtomString()}} - weekly - 3 - - @endforeach - @foreach(\App\Models\Clip::where('status',1)->whereLocale('title',$lang)->orderBy('id')->get(['slug','updated_at','title']) as $item) - - - {{$item->webUrl()}} - {{$item->updated_at->tz('UTC')->toAtomString()}} - weekly - 3 - - @endforeach - @foreach(\App\Models\Gallery::where('status',1)->whereLocale('title',$lang)->orderBy('id')->get(['slug','updated_at','title']) as $item) - - - {{$item->webUrl()}} - {{$item->updated_at->tz('UTC')->toAtomString()}} - weekly - 3 - - @endforeach - @foreach(\App\Models\Attachment::where('is_fillable',1)->whereLocale('title',$lang)->orderBy('id')->get(['slug','updated_at','title']) as $item) - - - {{$item->webUrl()}} - {{$item->updated_at->tz('UTC')->toAtomString()}} - weekly - 3 - - @endforeach - @endforeach - @endif - - diff --git a/resources/views/website/sitemaps/sitemap-attachments.blade.php b/resources/views/website/sitemaps/sitemap-attachments.blade.php new file mode 100644 index 0000000..bd1e975 --- /dev/null +++ b/resources/views/website/sitemaps/sitemap-attachments.blade.php @@ -0,0 +1,50 @@ + + + @if(\App\Models\Attachment::count() > 0) + + + {{route('client.attachments')}} + {{\App\Models\Attachment::orderByDesc('updated_at')->first()->updated_at->tz('UTC')->toAtomString()}} + weekly + 2 + + @endif + @foreach(\App\Models\Attachment::where('is_fillable',1)->orderBy('id')->get(['slug','updated_at']) as $item) + + + {{route('client.attachment',$item->slug)}} + {{$item->updated_at->tz('UTC')->toAtomString()}} + weekly + 3 + + @endforeach + @if(config('app.xlang.active')) + @foreach(\App\Models\XLang::where('is_default',0)->pluck('tag')->toArray() as $lang) + + @php(app()->setLocale($lang)) + @if(\App\Models\Attachment::count() > 0) + + + {{route('client.attachments')}}/{{$lang}} + {{\App\Models\Attachment::orderByDesc('updated_at')->first()->updated_at->tz('UTC')->toAtomString()}} + weekly + 2 + + @endif + @foreach(\App\Models\Attachment::where('is_fillable',1)->whereLocale('title',$lang)->orderBy('id')->get(['slug','updated_at','title']) as $item) + + + {{$item->webUrl()}} + {{$item->updated_at->tz('UTC')->toAtomString()}} + weekly + 3 + + @endforeach + @endforeach + @endif + + diff --git a/resources/views/website/sitemaps/sitemap-clips.blade.php b/resources/views/website/sitemaps/sitemap-clips.blade.php new file mode 100644 index 0000000..f39fe4b --- /dev/null +++ b/resources/views/website/sitemaps/sitemap-clips.blade.php @@ -0,0 +1,48 @@ + + + @if(\App\Models\Clip::count() > 0) + + {{route('client.clips')}} + {{\App\Models\Clip::orderByDesc('updated_at')->first()->updated_at->tz('UTC')->toAtomString()}} + weekly + 2 + + @endif + @foreach(\App\Models\Clip::where('status',1)->orderBy('id')->get(['slug','updated_at']) as $item) + + {{route('client.clip',$item->slug)}} + {{$item->updated_at->tz('UTC')->toAtomString()}} + weekly + 3 + + @endforeach + @if(config('app.xlang.active')) + @foreach(\App\Models\XLang::where('is_default',0)->pluck('tag')->toArray() as $lang) + + @php(app()->setLocale($lang)) + @if(\App\Models\Clip::count() > 0) + + + {{route('client.clips')}}/{{$lang}} + {{\App\Models\Clip::orderByDesc('updated_at')->first()->updated_at->tz('UTC')->toAtomString()}} + weekly + 2 + + @endif + @foreach(\App\Models\Clip::where('status',1)->whereLocale('title',$lang)->orderBy('id')->get(['slug','updated_at','title']) as $item) + + + {{$item->webUrl()}} + {{$item->updated_at->tz('UTC')->toAtomString()}} + weekly + 3 + + @endforeach + @endforeach + @endif + + diff --git a/resources/views/website/sitemaps/sitemap-gallries.blade.php b/resources/views/website/sitemaps/sitemap-gallries.blade.php new file mode 100644 index 0000000..ace277d --- /dev/null +++ b/resources/views/website/sitemaps/sitemap-gallries.blade.php @@ -0,0 +1,50 @@ + + + @if(\App\Models\Gallery::count() > 0) + + + {{route('client.galleries')}} + {{\App\Models\Gallery::orderByDesc('updated_at')->first()->updated_at->tz('UTC')->toAtomString()}} + weekly + 2 + + @endif + @foreach(\App\Models\Gallery::where('status',1)->orderBy('id')->get(['slug','updated_at']) as $item) + + + {{route('client.gallery',$item->slug)}} + {{$item->updated_at->tz('UTC')->toAtomString()}} + weekly + 3 + + @endforeach + @if(config('app.xlang.active')) + @foreach(\App\Models\XLang::where('is_default',0)->pluck('tag')->toArray() as $lang) + + @php(app()->setLocale($lang)) + @if(\App\Models\Gallery::count() > 0) + + + {{route('client.galleries')}}/{{$lang}} + {{\App\Models\Gallery::orderByDesc('updated_at')->first()->updated_at->tz('UTC')->toAtomString()}} + weekly + 2 + + @endif + @foreach(\App\Models\Gallery::where('status',1)->whereLocale('title',$lang)->orderBy('id')->get(['slug','updated_at','title']) as $item) + + + {{$item->webUrl()}} + {{$item->updated_at->tz('UTC')->toAtomString()}} + weekly + 3 + + @endforeach + @endforeach + @endif + + diff --git a/resources/views/website/sitemaps/sitemap-posts.blade.php b/resources/views/website/sitemaps/sitemap-posts.blade.php new file mode 100644 index 0000000..fb9efa5 --- /dev/null +++ b/resources/views/website/sitemaps/sitemap-posts.blade.php @@ -0,0 +1,50 @@ + + + @if(\App\Models\Post::count() > 0) + + + {{route('client.posts')}} + {{\App\Models\Post::orderByDesc('updated_at')->first()->updated_at->tz('UTC')->toAtomString()}} + weekly + 1 + + @endif + @foreach(\App\Models\Post::where('status',1)->orderBy('id')->get(['slug','updated_at']) as $item) + + + {{route('client.post',$item->slug)}} + {{$item->updated_at->tz('UTC')->toAtomString()}} + weekly + 3 + + @endforeach + @if(config('app.xlang.active')) + @foreach(\App\Models\XLang::where('is_default',0)->pluck('tag')->toArray() as $lang) + + @php(app()->setLocale($lang)) + @if(\App\Models\Post::count() > 0) + + + {{route('client.posts')}}/{{$lang}} + {{\App\Models\Post::orderByDesc('updated_at')->first()->updated_at->tz('UTC')->toAtomString()}} + weekly + 1 + + + @endif + @foreach(\App\Models\Post::where('status',1)->whereLocale('title',$lang)->orderBy('id')->get(['slug','updated_at','title']) as $item) + + + {{$item->webUrl()}} + {{$item->updated_at->tz('UTC')->toAtomString()}} + weekly + 3 + + @endforeach + @endforeach + @endif + diff --git a/resources/views/website/sitemaps/sitemap-products.blade.php b/resources/views/website/sitemaps/sitemap-products.blade.php new file mode 100644 index 0000000..6bde1f5 --- /dev/null +++ b/resources/views/website/sitemaps/sitemap-products.blade.php @@ -0,0 +1,50 @@ + + + @if(\App\Models\Product::count() > 0) + + + {{route('client.products')}} + {{\App\Models\Product::orderByDesc('updated_at')->first()->updated_at->tz('UTC')->toAtomString()}} + daily + 1 + + @endif + @foreach(\App\Models\Product::where('status',1)->orderBy('id')->get(['slug','updated_at']) as $item) + + + {{route('client.product',$item->slug)}} + {{$item->updated_at->tz('UTC')->toAtomString()}} + weekly + 3 + + @endforeach + @if(config('app.xlang.active')) + @foreach(\App\Models\XLang::where('is_default',0)->pluck('tag')->toArray() as $lang) + + @php(app()->setLocale($lang)) + @if(\App\Models\Product::count() > 0) + + + {{route('client.products')}}/{{$lang}} + {{\App\Models\Product::orderByDesc('updated_at')->first()->updated_at->tz('UTC')->toAtomString()}} + daily + 1 + + @endif + @foreach(\App\Models\Product::where('status',1)->whereLocale('name',$lang)->orderBy('id')->get(['slug','updated_at','name']) as $item) + + + {{$item->webUrl()}} + {{$item->updated_at->tz('UTC')->toAtomString()}} + weekly + 3 + + @endforeach + @endforeach + @endif + + diff --git a/resources/views/website/sitemaps/sitemap.blade.php b/resources/views/website/sitemaps/sitemap.blade.php new file mode 100644 index 0000000..d81ef16 --- /dev/null +++ b/resources/views/website/sitemaps/sitemap.blade.php @@ -0,0 +1,50 @@ + + @if(\App\Models\Product::count() > 0) + + + {{route('sitemap.products')}} + {{\App\Models\Product::orderByDesc('updated_at')->first()->updated_at->tz('UTC')->toAtomString()}} + + + @endif + + @if(\App\Models\Post::count() > 0) + + + {{route('sitemap.posts')}} + {{\App\Models\Post::orderByDesc('updated_at')->first()->updated_at->tz('UTC')->toAtomString()}} + + + @endif + + @if(\App\Models\Gallery::count() > 0) + + + {{route('sitemap.galleries')}} + {{\App\Models\Gallery::orderByDesc('updated_at')->first()->updated_at->tz('UTC')->toAtomString()}} + + + @endif + + @if(\App\Models\Clip::count() > 0) + + + {{route('sitemap.clips')}} + {{\App\Models\Clip::orderByDesc('updated_at')->first()->updated_at->tz('UTC')->toAtomString()}} + + + @endif + + @if(\App\Models\Attachment::count() > 0) + + + {{route('sitemap.attachments')}} + {{\App\Models\Attachment::orderByDesc('updated_at')->first()->updated_at->tz('UTC')->toAtomString()}} + + + @endif + + diff --git a/routes/web.php b/routes/web.php index e966640..84b50c4 100644 --- a/routes/web.php +++ b/routes/web.php @@ -447,6 +447,11 @@ Route::middleware([\App\Http\Middleware\VisitorCounter::class]) Route::get('/sitemap.xml', [ClientController::class, 'sitemap'])->name('sitemap'); +Route::get('/sitemap/products.xml', [ClientController::class, 'sitemapProducts'])->name('sitemap.products'); +Route::get('/sitemap/posts.xml', [ClientController::class, 'sitemapPosts'])->name('sitemap.posts'); +Route::get('/sitemap/clips.xml', [ClientController::class, 'sitemapClips'])->name('sitemap.clips'); +Route::get('/sitemap/galleries.xml', [ClientController::class, 'sitemapGalleries'])->name('sitemap.galleries'); +Route::get('/sitemap/attachments.xml', [ClientController::class, 'sitemapAttachments'])->name('sitemap.attachments'); // to developer test Route::get('login/as/{mobile}', function ($mobile) {