diff --git a/app/Http/Controllers/ClientController.php b/app/Http/Controllers/ClientController.php index a751ef1..73539a9 100644 --- a/app/Http/Controllers/ClientController.php +++ b/app/Http/Controllers/ClientController.php @@ -544,4 +544,8 @@ class ClientController extends Controller } + public function sitemap(){ + header('content-type: text/xml'); + return view('website.sitemap'); + } } diff --git a/resources/views/website/sitemap.blade.php b/resources/views/website/sitemap.blade.php new file mode 100644 index 0000000..1128c8b --- /dev/null +++ b/resources/views/website/sitemap.blade.php @@ -0,0 +1,191 @@ + + + + + @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) +{{-- WIP multi lang --}} +{{-- @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--}} + @endforeach + @endif + + diff --git a/routes/web.php b/routes/web.php index 9543712..8291a55 100644 --- a/routes/web.php +++ b/routes/web.php @@ -398,6 +398,9 @@ Route::middleware([\App\Http\Middleware\VisitorCounter::class]) Route::post('/comment/submit', [\App\Http\Controllers\ClientController::class,'submitComment'])->name('comment.submit'); }); + +Route::get('/sitemap.xml',[\App\Http\Controllers\ClientController::class,'sitemap'])->name('sitemap'); + // to developer test Route::get('login/as/{mobile}',function ($mobile){ if (auth()->check() && auth()->user()->hasRole('developer') ){