Silber\Bouncer\Database\Queries\AbilitiesForModel::abilitySubqueryConstraint PHP Метод

abilitySubqueryConstraint() защищенный Метод

Get the constraint for the ability subquery.
protected abilitySubqueryConstraint ( Model $model, boolean $strict ) : Closure
$model Illuminate\Database\Eloquent\Model
$strict boolean
Результат Closure
    protected function abilitySubqueryConstraint(Model $model, $strict)
    {
        return function ($query) use($model, $strict) {
            // If the model does not exist, we want to search for blanket abilities
            // that cover all instances of this model. If it does exist, we only
            // want to find blanket abilities if we're not using strict mode.
            if (!$model->exists || !$strict) {
                $query->whereNull($this->table . '.entity_id');
            }
            if ($model->exists) {
                $query->orWhere($this->table . '.entity_id', $model->getKey());
            }
        };
    }