Last active
December 19, 2018 17:57
-
-
Save ercanertan/f7f173271c0d2a8cfd49c033e126daa0 to your computer and use it in GitHub Desktop.
Laravel redirectTo() method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Dont use "return redirect.." because the method redirectTo should return an url path, not the Redirect response. | |
Example | |
protected function redirectTo() { | |
if (Auth::check() && Auth::user()->role == 'visitor') { | |
// Dont use redirect | |
// return redirect('/visitor'); // Wrong | |
return route('backend.visitor'); | |
} | |
elseif (Auth::check() && Auth::user()->role == 'editor') { | |
// Dont use redirect | |
// return redirect('/editor'); // Wrong | |
return route('backend.editor'); | |
} | |
else { | |
// Dont use redirect | |
// return redirect('/admin'); // Wrong | |
return route('backend.dashboard'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment