Skip to content

Instantly share code, notes, and snippets.

@robozavri
Created May 14, 2018 13:21
Show Gist options
  • Save robozavri/1e239501941b68498d8553f5a7c9b6c7 to your computer and use it in GitHub Desktop.
Save robozavri/1e239501941b68498d8553f5a7c9b6c7 to your computer and use it in GitHub Desktop.
laraadmin laravel admin redirect if is admin
namespace App\Http\Controllers\Auth;
class LoginController extends Controller
public function redirectTo(){
$roles = Auth::user()->roles;
if(!is_null($roles )){
foreach (Auth::user()->roles as $role) {
if($role->name == "SUPER_ADMIN"){
return '/admin';
}
}
}
return $this->redirectTo;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment