1 year ago

L5.8 - Dynamic Prefix to include an id

Posted 1 year ago by laracastsluvr

Hello friends,

Got another one! A question that is ;)

Is there an efficient way to have a view (a dashboard for example) display certain settings based on a route prefix with a property ID?

For example:


The abobe example should fetch messages of a store with store_id = x. Also after all Authentication and Authorization is passed!

My first thought was after the user logs in, they would be presented with a selector page to pick which "store/entity" they would like to proceed in working with.

Hello, please select the store you would like to access

Store 1 link -> domain.tld/store/1001/
Store 2 link -> domain.tld/store/1010/
Route::group(['prefix' => 'store/{store_id}'], function() {
    Route::get('/', function() {

    Route::get('settings', function() {

    Route::get('messages/{id}', function() {

Or should I scrap this idea and go with a session key that stores the selected store_id from the "selector" entry page then access it every time on the app's controllers?

Any advice or another way possible?

Please sign in or create an account to participate in this conversation.