Silber\Bouncer\Clipboard::findMatchingAbility PHP Method

findMatchingAbility() protected method

Determine if any of the abilities can be matched against the provided applicable ones.
protected findMatchingAbility ( Collection $abilities, Collection $applicable, Model $model, Model $authority ) : integer | null
$abilities Illuminate\Support\Collection
$applicable Illuminate\Support\Collection
$model Illuminate\Database\Eloquent\Model
$authority Illuminate\Database\Eloquent\Model
return integer | null
    protected function findMatchingAbility($abilities, $applicable, $model, $authority)
    {
        $abilities = $abilities->toBase()->pluck('identifier', 'id');
        if ($id = $this->getMatchedAbilityId($abilities, $applicable)) {
            return $id;
        }
        if ($model instanceof Model && Models::isOwnedBy($authority, $model)) {
            return $this->getMatchedAbilityId($abilities, $applicable->map(function ($identifier) {
                return $identifier . '-owned';
            }));
        }
    }