Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Brand3000's avatar

Perfect redirects

Hello everybody! I'm wondering if someone already has a realization of comprehensive redirects to the index after creating or updating a resource for different scenarios considering pagination. relations, etc.?

0 likes
12 replies
gpalmer711's avatar

I'm not sure if this is what you are looking for, but Nova has some built in methods for redirecting after Create/Update/Delete actions - https://nova.laravel.com/docs/4.0/resources/#redirection

If you are wanting to preserve pagination page or similar, I think you would need to store the current page in a session var or similar? Then use that value when the index page is loaded.

You could then use the indexFilter method to indicate the page that you wish to view - https://nova.laravel.com/docs/4.0/resources/authorization.html#index-filtering

Brand3000's avatar

@gpalmer711 Thank you very much for your attention. Yes, I know about suggested features, but I'm searching something like a package or a trait to include and just use. It's a dream, right? =) There're a bunch of scenarios not to forget (I don't want to list them up), bit the general approach with sessions is the first to consider.

I think, I'll start implementing this feature myself on Monday.

Thank you.

Snapey's avatar

@Brand3000 yes its a dream

Too many variations for a simple package.

Perhaps define some specific problems and you might get some specific answers

Brand3000's avatar

@Snapey The request of my client is very simple. He doesn't want to see that detail page after creating/updating a record. To be honest, I agree with him. There's more uselessness than usefulness. Going back where an administrator had been before is more time consuming =(

Brand3000's avatar

@Snapey On the other hand, from the very first thought it seems that by saving all the steps (urls) to a session variable without the edit resource url might be helpful.

Snapey's avatar

@Brand3000 so redirect to the index page after store or update. Where is the complication?

Brand3000's avatar

@Snapey I might edit a record from a second, third page, I might apply some sorting and again be on the second page. Additionally, we can add relations in my scenarios, filters, search, lens,.....

Snapey's avatar

@Brand3000 so the index page has state, as represented in the url (assuming you can refresh the index page and arrive at the same state with pagination or searches or whatever.

You have (at least) two options. 1, store the query string until you need it back, eg in session or pass it along through editing via a hidden form input or, 2, avoid the issue by performing edit in a modal, thus leaving index intact.

Brand3000's avatar

@Snapey The modal would be a very good decision. Don't you know if there is something on the internet for this purpose?

Please or to participate in this conversation.