Delete the one and last data from page of pagination and return to page with content
Hey,
I use jetstream with inertiajs and vue 3. I delete the one paginator data in last page and redirect to the same page without content. I try to figure out how to redirect to first page with content/data without return to previous page without data.
For example I have 2 pages and every paginator page have 9 items in total, but the second one have only one item. I delete the only one data from the second page and redirect to the same page (second page) but I want to redirect to the first page because have data/items.
Any idea how to avoid or fix that?
#1 Edit
I follow the Jeffrey Way tutorial on youtube...
@Sinnbeck Thanks for your reply.
I think of that but the return is the render of inertia? What part of code do you want to show?
This a part of laravel
public function index()
{
$user = Auth::user();
return Inertia::render('Links/Index', [
'links' => $user->links()->paginate(9),
]);
}
@ImWaller Bingo. Change that to redirect to the route
public function destroy(Link $link)
{
$link->delete();
return redirect('/url-to-the-page');
}
//or
public function destroy(Link $link)
{
$link->delete();
return redirect()->route('name_of_route');
}