@archiebango You can use middleware for this.
public function handle($request, Closure $next)
{
$user_role = User::with(‘role’)->find(Auth::id());
if ($user->role->name == ‘admin’)
{
return redirect()->to(‘/admin’);
}
return redirect()->to(‘/‘);
}
You can create a helper class and put it there. It all depends on how and when you want to trigger it.
The code above assumes you have the following relationship
- a user belongs to a role
- a role has many users
If you use middleware, you can call it at a controller’s construct(). If you use a helper, you can use it let’s say right after a successful login. There are many ways to implement what you’re trying to do. Hope this gives you an idea.