I want to redirect to the user's dashboard according to role. I have created a separate table for the user role and a separate table for the user. I don't understand how I can do that.
This is my middleware code
public function handle(Request $request, Closure $next)
{
if(!Auth::check()){
return redirect()->route('login.user')->with('error', 'Please login first');
}
if(Auth::user()->role == 1){
return $next($request);
}
if(Auth::user()->role == 2){
return redirect()->route('user.dashboard');
}
}
This is my user role table
| id | user_type |
|---|---|
| 1 | admin |
| 2 | user |
This is my user table
| id | user_name | user_role_id |
|---|---|---|
| 1 | admin | 1 |
| 2 | user | 2 |
I would be very happy if you could help me.