diff --git a/app/Http/Controllers/MemeController.php b/app/Http/Controllers/MemeController.php index 8f0b09b..82a7041 100644 --- a/app/Http/Controllers/MemeController.php +++ b/app/Http/Controllers/MemeController.php @@ -33,6 +33,33 @@ class MemeController extends Controller SEOTools::setTitle('Home'); $data = [ 'memes' => Meme::with(['user', 'tips'])->orderByDesc('created_at')->paginate(20), + 'pt-0' => true, + ]; + return view('homepage', ['data' => $data]); + } + + public function mostTipped() + { + SEOTools::setTitle('Most Tipped Memes'); + $query = \DB::select("SELECT meme_id FROM `tips` GROUP BY meme_id ORDER BY SUM(AMOUNT) DESC"); + $ids = array_column($query, 'meme_id'); + $memes = Meme::with(['user', 'tips'])->whereIn('id', $ids)->orderByRaw("field(id,".implode(',',$ids).")")->paginate(20); + $data = [ + 'memes' => $memes, + 'pt-0' => true, + ]; + return view('homepage', ['data' => $data]); + } + + public function recentlyTipped() + { + SEOTools::setTitle('Recently Tipped Memes'); + $query = \DB::select("SELECT meme_id FROM `tips` ORDER BY created_at DESC"); + $ids = array_unique(array_column($query, 'meme_id')); + $memes = Meme::with(['user', 'tips'])->whereIn('id', $ids)->orderByRaw("field(id,".implode(',',$ids).")")->paginate(20); + $data = [ + 'memes' => $memes, + 'pt-0' => true, ]; return view('homepage', ['data' => $data]); } diff --git a/resources/views/homepage.blade.php b/resources/views/homepage.blade.php index 1748d98..00cb255 100644 --- a/resources/views/homepage.blade.php +++ b/resources/views/homepage.blade.php @@ -2,8 +2,28 @@ @section('content') +
+
+
+
+
+

XMR Memes

+

Get tipped Monero (XMR) for making memes about Monero.

+
+
+
+
+
+
+
@foreach ($data['memes'] as $meme) diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index 0ca93b1..b79c5e7 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -115,9 +115,16 @@
-
- @yield('content') -
+ + @if (isset($data['pt-0'])) +
+ @yield('content') +
+ @else +
+ @yield('content') +
+ @endif