From 4b3d04ff54ebed420afeec7683dff44c42761289 Mon Sep 17 00:00:00 2001 From: Refringe Date: Thu, 29 Aug 2024 16:45:11 -0400 Subject: [PATCH] Mod Filter - Redirect To Last Page If the page you're on doesn't have any results, then redirect to the last page that does. --- app/Livewire/Mod/Index.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/Livewire/Mod/Index.php b/app/Livewire/Mod/Index.php index 3cc2c34..8ab4165 100644 --- a/app/Livewire/Mod/Index.php +++ b/app/Livewire/Mod/Index.php @@ -88,6 +88,11 @@ class Index extends Component ]; $mods = (new ModFilter($filters))->apply()->paginate(16); + // Check if the current page is greater than the last page. Redirect if it is. + if ($mods->currentPage() > $mods->lastPage()) { + $this->redirectRoute('mods', ['page' => $mods->lastPage()]); + } + return view('livewire.mod.index', compact('mods')); }