isOwnedBy() public static method

Determines whether the given model is owned by the given authority.
public static isOwnedBy ( Model $authority, Model $model ) : boolean
$authority Illuminate\Database\Eloquent\Model
$model Illuminate\Database\Eloquent\Model
return boolean
コード例 #1
0
ファイル: Clipboard.php プロジェクト: JosephSilber/bouncer
 /**
  * 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';
         }));
     }
 }