daily pastebin goal
56%
SHARE
TWEET

login success redirect laravel depend on role

rodro1 Jan 23rd, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top