Last active
December 17, 2019 21:49
Add this code to all the middleware and route according to the user roles
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
<?php | |
namespace App\Http\Middleware; | |
use Auth; | |
use Closure; | |
class Player | |
{ | |
/** | |
* Handle an incoming request. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @param \Closure $next | |
* @return mixed | |
*/ | |
public function handle($request, Closure $next) | |
{ | |
if (!Auth::check()) { | |
return redirect()->route('login'); | |
} | |
if (Auth::user()->role == 1) { | |
return redirect()->route('superadmin'); | |
} | |
if (Auth::user()->role == 5) { | |
return redirect()->route('academy'); | |
} | |
if (Auth::user()->role == 6) { | |
return redirect()->route('scout'); | |
} | |
if (Auth::user()->role == 4) { | |
return redirect()->route('team'); | |
} | |
if (Auth::user()->role == 3) { | |
return $next($request); | |
} | |
if (Auth::user()->role == 2) { | |
return redirect()->route('admin'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment