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());
            }
        };
    }