diff options
| author | horus | 2020-03-24 17:18:39 +0100 |
|---|---|---|
| committer | horus | 2020-03-24 17:18:39 +0100 |
| commit | 74e73666e5f79fe5862bc9cd2c8d244004c381b4 (patch) | |
| tree | a062e461d0be935993161ca07a8b0f8cddf2f911 /app/Http/Controllers/AnimeController.php | |
| parent | d68ed7e017f5a6bedb78c46af88dbc9cb7e881d7 (diff) | |
| download | senpai-74e73666e5f79fe5862bc9cd2c8d244004c381b4.tar.gz | |
Integrate chart.js to display anime stats.
Diffstat (limited to 'app/Http/Controllers/AnimeController.php')
| -rw-r--r-- | app/Http/Controllers/AnimeController.php | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/app/Http/Controllers/AnimeController.php b/app/Http/Controllers/AnimeController.php index d43b1f8..9bbd3e8 100644 --- a/app/Http/Controllers/AnimeController.php +++ b/app/Http/Controllers/AnimeController.php @@ -20,17 +20,34 @@ class AnimeController extends Controller { public function showAnime($mal_id) { $anime = Anime::where('mal_id', $mal_id)->get()->first(); + if ( is_null($anime) ) { + abort(404); + } $anime["stats"] = $anime->getStats()->orderBy('created_at', 'asc')->get(); foreach( $anime["stats"] as $stats ) { $score[] = $stats->score; - $scored_at[] = $stats->created_at->toDateString(); + $created_at[] = $stats->created_at->toDateString(); + $rank[] = $stats->rank; + $popularity[] = $stats->popularity; + $members[] = $stats->members; + $favorites[] = $stats->favorites; } $anime["score"] = $score; - $anime["score_label"] = $scored_at; + $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::get(); + + return view('index_anime', ["all_anime" => $anime]); + } } |
