lundi 4 janvier 2016

Different controller depending on user role - Laravel 5.1

I'm not sure if this is good or bad practice, but I'm trying to load the same route with a different controller / method depending on the user role.

Tried to some role filtering like not sure if this is the way to go:

Route::group(['before' => 'role:admin'], function() {
   Route::get('/', 'FirstController@index');
});

Route::group(['before' => 'role:editor'], function() {
   Route::get('/', 'SecondController@index');
});


Route::filter('role', function($route, $request, $value) {
   // what to do here and is this the right way?
});

But I don't get it to work. How can I accomplish this?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire