Support the ongoing development of Laravel.io →
posted 9 years ago
Session
Last updated 2 years ago.
0

is there more than one "library"? why not use a named route.

<a href="{{{ URL::route('library') }}}">Back</a>

and

Route::get('/library', ['uses' => 'LibraryController@dashboard', 'as' => 'library']);

Or is the library page dynamic? I am lost. This seems like it is quite simple as long as the library page url doesn't change.

Not really sure what the issue is :)

0

Hi,

Thanks for your reply.

The issue is that these pages can be accessed from a few places. The 'library' was just once example to illustrate. So, for instance, the item show page can also be accessed from a 'Story' page. So, a named route back isn't an option. I did do this originally, just so we went back to somewhere logical, but it ruins the flow for the user.

Also, as mentioned above, the item edit route can be access from either the item show or library (and, once I get round to it, from other 'archive' pages). So, it's quite complex.'

Oh, and yes, you can access from different 'library' pages - 'library' and 'userLibrary', as well as other pages.

FYI, the routes for these library pages are:

Route::get('library', ['as' => 'library', 'uses' => 'ItemsController@library']);

Route::get('userLibrary', ['as' => 'userLibrary', 'uses' => 'ItemsController@userLibrary']);
Last updated 9 years ago.
0

You could create a middleware or filter. Capture the http_referer Capture the current url including query strings

Compare them, if different put referer in a session e.g. RefererUrl Use this key on all your back or cancel buttons

0

Thanks for that Edwin.

I did try the filter idea, but the issue here was that the filter would get triggered each time I came back to the show page, from the edit screen too. So, the 'back' button on this page would then go back to edit, instead of the original referrer (library); similar to doing a URL::previous();, if you see what I mean.

This is why I placed the current URL in a session within the previous action (as shown above in my code), so that the url being used for the 'Back' would remain unchanged. The issue here is that I have to create 'named' referrers for each page with a 'Back' button, which is the solution I opted for. But doesn't seem entirely elegant!

Never done anything with middleware classes, so I'll check that out. Thanks for that... But I suspect, I'll have the same 'looping' problem as mentioned above.

So, it sounds like the best approach is to just carry on with my solution as it is, unless someone has any other ideas?

Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

tnaseem tnaseem Joined 9 Jan 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.