Is this possible something like this:
if(Auth::user()->isCompany()){
$middleware = "auth.company";
$namespace = 'Company';
} else {
$middleware = "auth.admin";
$namespace = null;
}
Route::group(['prefix' => 'admin'], 'middleware' => $middleware , 'namespace' => $namespace , function(){
Route::get('/','AdminController@getIndex');
Route::get('users', 'UsersController@getIndex');
});
I basically want to use the same route ( and sub-routes) but would behave different controllers handling them based on a condition. For this instance let's say a user role . I wouldn't like to put it on the same controller because it would mess up the controller with lots of conditionals.
The problem here is I couldn't access Auth, How should I go about this?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community