Edit File: web.php
<?php use Carbon\Carbon; use App\Models\Tag; use App\Models\Page; use App\Models\Anime; use App\Models\Genre; use App\Models\Video; use App\Models\Season; use Spatie\Sitemap\Sitemap; use Spatie\Sitemap\Tags\Url; use App\Livewire\SearchAnime; use App\Livewire\Show\TagShow; use App\Livewire\Show\AnimeShow; use App\Livewire\Show\GenreList; use App\Livewire\Show\GenreShow; use App\Livewire\Show\VideoShow; use App\Livewire\Show\SeasonShow; use App\Livewire\Show\SocialShow; use App\Livewire\Show\CompletedFilm; use App\Livewire\Show\CompletedAnime; use App\Livewire\Show\SeasonListShow; use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Response; use App\Livewire\Dashboard\FollowedAnime; Route::get('/', function () { $animes = Anime::where("is_film", false)->inRandomOrder()->limit(5)->get(); $films = Anime::where("is_film", true)->inRandomOrder()->limit(5)->get(); $home_sliders = $animes->concat($films); $on_going_animes = Anime::with("tags")->where("is_film", false)->where("is_completed", false)->inRandomOrder()->limit(40)->get(); $new_release_films = Anime::where("is_film", true)->orderByDesc("created_at")->limit(40)->get(); $completed = Anime::with("tags")->where("is_film", false)->where("is_completed", true)->inRandomOrder()->limit(40)->get(); $page = Page::latest()->first(); $last_season = Season::with("animes")->orderByDesc("order")->skip(1)->first(); return view("welcome", compact("home_sliders", 'on_going_animes', 'completed', 'page', 'new_release_films', 'last_season')); })->name("home"); Route::prefix("dashboard")->middleware(["auth"])->group(function () { // Route::view('/', 'dashboard')->name('dashboard'); Route::get('/', function () { return redirect()->route('anime.follow'); })->name('dashboard'); Route::get("/follow", FollowedAnime::class)->name("anime.follow"); }); Route::get("/search/{query}", SearchAnime::class)->name("anime.search"); Route::view('profile', 'profile') ->middleware(['auth']) ->name('profile'); Route::get("/anime/completed", CompletedAnime::class)->name("completed.show"); Route::get("/film-list", CompletedFilm::class)->name("filmlist"); Route::get("/anime/{slug}", AnimeShow::class)->name("anime.show"); Route::get("/anime/{slug}/episode/{order}", VideoShow::class)->name("video.show"); Route::get("/season/list", SeasonListShow::class)->name("season.show.list"); Route::get("/season/{slug}", SeasonShow::class)->name("season.show"); Route::get("/tag/{slug}", TagShow::class)->name("tag.show"); Route::get("/genre/list", GenreList::class)->name("genre.show.list"); Route::get("/genre/{slug}", GenreShow::class)->name("genre.show"); Route::get("/media-sosial", SocialShow::class)->name("social.show"); Route::get('/sitemap.xml', function () { $sitemap = Sitemap::create(); // ✅ Static routes $sitemap->add(Url::create('/anime/completed')); $sitemap->add(Url::create('/film-list')); $sitemap->add(Url::create('/season/list')); $sitemap->add(Url::create('/genre/list')); $sitemap->add(Url::create('/media-sosial')); // ✅ Anime routes Anime::all()->each(function ($anime) use ($sitemap) { $sitemap->add( Url::create("/anime/{$anime->slug}") ->setLastModificationDate($anime->updated_at ?? Carbon::now()) ); }); // ✅ Episode per anime (dinamis) Anime::with('videos')->get()->each(function ($anime) use ($sitemap) { foreach ($anime->videos as $video) { $sitemap->add( Url::create("/anime/{$anime->slug}/episode/{$video->order}") ->setLastModificationDate($video->updated_at ?? Carbon::now()) ); } }); // ✅ Season show Season::all()->each(function ($season) use ($sitemap) { $sitemap->add( Url::create("/season/{$season->slug}") ->setLastModificationDate($season->updated_at ?? Carbon::now()) ); }); // ✅ Tag show Tag::all()->each(function ($tag) use ($sitemap) { $sitemap->add( Url::create("/tag/{$tag->slug}") ->setLastModificationDate($tag->updated_at ?? Carbon::now()) ); }); // ✅ Genre show Genre::all()->each(function ($genre) use ($sitemap) { $sitemap->add( Url::create("/genre/{$genre->slug}") ->setLastModificationDate($genre->updated_at ?? Carbon::now()) ); }); return $sitemap->toResponse(request()); }); require __DIR__ . '/auth.php'; require __DIR__ . '/admin.php'; require __DIR__ . '/movie.php';
Back