ajax()) { return response('Unauthorized.', 401); } else { return redirect()->guest('/login'); } } //if (! $request->user()->hasRole($role)) //{ // abort(401); //} foreach ($request->user()->roles()->get() as $role) { if ($role->hasPermissionTo($permission)) { return $next($request); } //break(1); } //if (! $request->user()->can($permission)) //{ // abort(401); //} return abort(401); //return $next($request); } }