/** * Authorize the request at the given gate. * * @param \Illuminate\Contracts\Auth\Access\Gate $gate * @param mixed $ability * @param mixed|array $arguments * @return \Illuminate\Auth\Access\Response * * @throws \Symfony\Component\HttpKernel\Exception\HttpException */ public function authorizeAtGate(Gate $gate, $ability, $arguments) { try { return $gate->authorize($ability, $arguments); } catch (UnauthorizedException $e) { throw $this->createGateUnauthorizedException($ability, $arguments, $e->getMessage(), $e); } }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param string $ability * @param array|null $models * @return mixed * * @throws \Illuminate\Auth\AuthenticationException * @throws \Illuminate\Auth\Access\AuthorizationException */ public function handle($request, Closure $next, $ability, ...$models) { $this->auth->authenticate(); $this->gate->authorize($ability, $this->getGateArguments($request, $models)); return $next($request); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param string $ability * @param string|null $model * @return mixed * * @throws \Illuminate\Auth\Access\AuthorizationException */ public function handle($request, Closure $next, $ability, $model = null) { $this->gate->authorize($ability, $this->getGateArguments($request, $model)); return $next($request); }