vendredi 22 juin 2018

Use different route namespace based on middleware in Laravel

I have the following code in my routes/web.php

Route::namespace('Admin')->middleware(['admin'])->group(function() {
    Route::get('/posts', 'PostController@index');
});

Route::namespace('User')->middleware(['user'])->group(function() {
    Route::get('/posts', 'PostController@index');
});

I wish to use the same uri "/posts" in both cases and keep the role logic (admin, user) out of the controllers, however, in this case, when I request the route "/posts" in always responds with the last one.

I can't seem to find information of what I am missing here.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire