get()->first(); if ( is_null($anime) ) { abort(404); } /** * Redirects to correct slug. */ if ( $slug != Str::slug($anime->title_pref) ) { return redirect()->route('anime', ["mal_id" => $anime->mal_id, "slug" => Str::slug($anime->title_pref)]); } $anime["stats"] = $anime->getStats()->orderBy('created_at', 'asc')->get(); foreach( $anime["stats"] as $stats ) { $score[] = $stats->score; $created_at[] = $stats->created_at->toDateString(); $rank[] = $stats->rank; $popularity[] = $stats->popularity; $members[] = $stats->members; $favorites[] = $stats->favorites; } $anime["score"] = $score; $anime["rank"] = $rank; $anime["popularity"] = $popularity; $anime["members"] = $members; $anime["favorites"] = $favorites; $anime["chart_label"] = $created_at; $anime["basic_data"] = DB::select('select score, rank, popularity, members, favorites from anime join stats on stats.id = ( select id from stats where anime.mal_id = stats.mal_id order by created_at desc limit 1) where anime.mal_id = ?', [$mal_id])[0]; return view('anime', [ "anime" => $anime ]); } public function showAllAnime() { $anime = Anime::simplePaginate(); return view('index_anime', ["all_anime" => $anime]); } }