Advertisement
rodro1

login success redirect laravel depend on role

Jan 23rd, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. You can do this handle the request in the Middleware RedirectIfAuthenticated.php inside the handle function like this:
  2.  
  3. /**
  4. * Handle an incoming request.
  5. *
  6. * @param \Illuminate\Http\Request $request
  7. * @param \Closure $next
  8. * @param string|null $guard
  9. * @return mixed
  10. */
  11. public function handle($request, Closure $next, $guard = null)
  12. {
  13. if (Auth::guard($guard)->check()) {
  14. if (Auth::user()->role == 'admin') {
  15. return redirect('/admin');
  16. }else{
  17. return redirect('/');
  18. }
  19. }
  20.  
  21. return $next($request);
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement