Laravel already has authorization, and you can use them with middleware. read this https://laravel.com/docs/5.3/authorization#via-middleware
class CheckRole
{
public function handle(Request $request, Closure $next, $role)
{
$user = $request->user();
if (! $user->role == $role) {
return redirect(...);
}
return $next($request);
}
}
'middleware' => ['hasrole:1']
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community