summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorhorus2020-03-19 02:57:17 +0100
committerhorus2020-03-19 02:57:17 +0100
commit224d4d32ba3a3827f1b0131a1f1c81b660d5d8d8 (patch)
tree8fc7f2e2bb485d4b86ca71ecf024d961bc74993b /app
parent9436a3cd81d593de15653840ce4f69cee5cb573f (diff)
downloadsenpai-224d4d32ba3a3827f1b0131a1f1c81b660d5d8d8.tar.gz
Adds landing page for specific anime + first chart.
Diffstat (limited to 'app')
-rw-r--r--app/Http/Controllers/AnimeController.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/app/Http/Controllers/AnimeController.php b/app/Http/Controllers/AnimeController.php
new file mode 100644
index 0000000..d43b1f8
--- /dev/null
+++ b/app/Http/Controllers/AnimeController.php
@@ -0,0 +1,36 @@
+<?php
+
+namespace App\Http\Controllers;
+use Illuminate\Support\Facades\Cache;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Http\Request;
+use Illuminate\Http\Response;
+
+use App\Anime;
+use App\AnimeStats;
+
+use Carbon\Carbon;
+
+class AnimeController extends Controller {
+ /**
+ * Shows the index page.
+ *
+ * @return Response
+ */
+ public function showAnime($mal_id) {
+
+ $anime = Anime::where('mal_id', $mal_id)->get()->first();
+ $anime["stats"] = $anime->getStats()->orderBy('created_at', 'asc')->get();
+
+ foreach( $anime["stats"] as $stats ) {
+ $score[] = $stats->score;
+ $scored_at[] = $stats->created_at->toDateString();
+ }
+ $anime["score"] = $score;
+ $anime["score_label"] = $scored_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 ]);
+ }
+}