My route is
Route::resource('product', 'Product\ProductController');
My ProductController
public function index(){
$role = Auth::User()->roles->first()->name;
$this->roleName = str_replace(' ', '', $role);
return app('App\Http\Controllers\Product'. '\\'. $this->roleName. 'ProductController')->index();
}
Everything works fine it triggers AdminProductController
or AreaManagerProductController
and in the service providers
$this->app->when(AdminController::class)
->needs(UserInterface::class)
->give(AdminRepository::class);
$this->app->when(AreaManagerProductController::class)
->needs(UserInterface::class)
->give(AreaManagerRepository::class);
The problem is... it doesn't trigger $this->middleware('sample')
both controllers. Is there a better way to do this? Thanks.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community