public function __construct()
{
if (Auth::check()){
if(Auth::user()->user_type == 'admin'){
return to_route('admin.dashboard');
} elseif(Auth::user()->user_type == 'operator'){
return to_route('operator.dashboard');
}
}
}
I am checking user authentication.
2
Answers
Create a controller method, don’t do it in the constructor. Constructors in Laravel controllers do not typically return values.
It’s not possible by design. If you need it you can create middleware in constructor like this:
but you can also create normal middleware and use it for controller.
See this Laravel change to get more explanation