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') +
Get tipped Monero (XMR) for making memes about Monero.
+