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.
This commit is contained in:
Refringe 2024-08-29 16:45:11 -04:00
parent 1783a683ed
commit 4b3d04ff54
Signed by: Refringe
SSH Key Fingerprint: SHA256:t865XsQpfTeqPRBMN2G6+N8wlDjkgUCZF3WGW6O9N/k

View File

@ -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'));
}