/** * Determine if any of the abilities can be matched against the provided applicable ones. * * @param \Illuminate\Support\Collection $abilities * @param \Illuminate\Support\Collection $applicable * @param \Illuminate\Database\Eloquent\Model $model * @param \Illuminate\Database\Eloquent\Model $authority * @return int|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'; })); } }