Determine if the given ability should be granted.

@param  string $ability
@param  array|mixed $arguments
@return bool
554004
public function check($ability, $arguments = [])
    {
        if (!is_array($arguments)) {
            $arguments = [ $arguments ];
        }

        array_unshift($arguments, $ability);
        return call_user_func_array([ $this->gatekeeper, 'check'], $arguments);
    }
252536
protected function checkAtClipboard(Model $authority, $ability, $model)
    {
        if ($id = $this->clipboard->checkGetId($authority, $ability, $model)) {
            return $this->allow('Bouncer granted permission via ability #'.$id);
        }

        // If the response from "checkGetId" is "false", then this ability
        // has been explicity forbidden. We'll return false so the gate
        // doesn't run any further checks. Otherwise we return null.
        return $id;
    }
260396
final public function can($ability)
    {
        if (! $this->abilities->has($ability)) {
            return false;
        }
        $value = $this->abilities->get($ability);

        return $value($this) ? true : false;
    }
525261
public function canRun($arguments = [])
    {
        $action = 'action' . ucfirst($this->getActiveAction());
        return $this->canCallMethod($action, $arguments ? $arguments : ($this->request ? $this->request->getParams() : []));
    }
1243207
public function authorizeAtGate(GateInterface $gate, $ability, $arguments)
    {
        try {
            return $gate->authorize($ability, $arguments);
        }
        catch (UnauthorizedException $e) {
            $exception = $this->createGateUnauthorizedException($ability, $arguments, $e->getMessage(), $e);

            throw $exception;
        }
    }
82243
protected function callAuthCallback(User $user, $ability, array $arguments)
    {
        $callback = $this->resolveAuthCallback($user, $ability, $arguments);

        return call_user_func_array($callback, array_merge(array($user), $arguments));
    }
344964
public function getAbilities(Model $authority, $allowed = true)
    {
        return Abilities::forAuthority($authority, $allowed)->get();
    }
256196
public function can($ability, $arguments = [])
    {
        foreach ($this->abilities as $check) {
            if (fnmatch($check, $ability)) {
                return true;
            }
        }

        return false;
    }
119759
protected static function hasTypeAccessBelongs(array $capabilities, array $user, array $url): bool
    {
        $entity = static::getEntityFromUrl($url);

        $userGroups = static::getUserGroups($user);

        foreach ($capabilities as $capability) {
            if (!static::hasAccessInCapabilities($capability->getName(), $user['id'])) {
                continue;
            }

            // if url does not include an id and user has belongs to capability
            // access, to current module action, allow him access. (index action)
            if (empty($entity)) {
                return true;
            }

            // if url includes an id, check capability's field value from the entity
            // against current user id and if they match allow him access. (view, edit actions etc)
            $field = $capability->getField();

            foreach (array_keys($userGroups) as $id) {
                if ($entity->get($field) === $id) {
                    return true;
                }
            }
        }

        return false;
    }
1352392
protected function isSpecificModelAbility(Model $ability)
    {
        return $ability->entity_type !== '*'
            && ! is_null($ability->entity_type)
            && ! is_null($ability->entity_id);
    }
1345111
protected function findAbility($ability, $entity, $attributes)
    {
        $onlyOwned = isset($attributes['only_owned']) ? $attributes['only_owned'] : false;

        $query = Models::ability()
                     ->where('name', $ability)
                     ->forModel($entity, true)
                     ->where('only_owned', $onlyOwned);

        return Models::scope()->applyToModelQuery($query)->first();
    }
587748
protected function parseAbilityAndArguments($ability, $arguments)
    {
        if (is_string($ability) && (strpos($ability, '\\') === false)) {
            return array($ability, $arguments);
        }

        list(,, $caller) = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);

        return array($this->normalizeGuessedAbilityName($caller['function']), $ability);
    }
749216
protected function resolveAuthCallback($user, $ability, array $arguments)
    {
        if (isset($arguments[0]) &&
            ! is_null($policy = $this->getPolicyFor($arguments[0])) &&
            $callback = $this->resolvePolicyCallback($user, $ability, $arguments, $policy)) {
            return $callback;
        }

        if (isset($this->stringCallbacks[$ability])) {
            [$class, $method] = Str::parseCallback($this->stringCallbacks[$ability]);

            if ($this->canBeCalledWithUser($user, $class, $method ?: '__invoke')) {
                return $this->abilities[$ability];
            }
        }

        if (isset($this->abilities[$ability]) &&
            $this->canBeCalledWithUser($user, $this->abilities[$ability])) {
            return $this->abilities[$ability];
        }

        return function () {
        };
    }
939703
protected function raw($ability, array $arguments)
    {
        if (is_null($user = $this->resolveUser())) {
            return false;
        }

        $result = $this->callBeforeCallbacks($user, $ability, $arguments);

        if (is_null($result)) {
            $result = $this->callAuthCallback($user, $ability, $arguments);
        }

        $this->callAfterCallbacks($user, $ability, $arguments, $result);

        return $result;
    }
845180
public function check(Model $authority, $ability, $model = null)
    {
        return (bool) $this->checkGetId($authority, $ability, $model);
    }
873376
protected static function hasTypeAccessFull(array $capabilities, array $user, array $url): bool
    {
        foreach ($capabilities as $capability) {
            if (static::hasAccessInCapabilities($capability->getName(), $user['id'])) {
                return true;
            }
        }

        return false;
    }
734082
public function checkGetId(Model $authority, $ability, $model = null)
    {
        if ($this->isForbidden($authority, $ability, $model)) {
            return false;
        }

        $ability = $this->getAllowingAbility($authority, $ability, $model);

        return $ability ? $ability->getKey() : null;
    }