本文整理汇总了PHP中Illuminate\Database\Eloquent\Builder::whereNull方法的典型用法代码示例。如果您正苦于以下问题:PHP Builder::whereNull方法的具体用法?PHP Builder::whereNull怎么用?PHP Builder::whereNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Eloquent\Builder
的用法示例。
在下文中一共展示了Builder::whereNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: apply
/**
* Applies parameter filtering for a given query
*
* @param string $name
* @param mixed $value
* @param EloquentBuilder $query
* @param FilterInterface $filter
* @return EloquentBuilder
*/
public function apply($name, $value, $query, FilterInterface $filter)
{
$column = (!empty($this->table) ? $this->table . '.' : null) . (!empty($this->column) ? $this->column : $name);
return $query->where(function ($query) use($column) {
return $query->whereNull($column)->orWhere($column, '');
});
}
示例2: execute
public function execute(Builder $query)
{
if ($this->group) {
return $query->where('group', '=', $this->group);
} else {
return $query->whereNull('group');
}
}
示例3: build
public function build(Builder $query)
{
if ($this->parentId) {
return $query->where('parent_id', '=', $this->parentId);
} else {
return $query->whereNull('parent_id');
}
}
示例4: build
/**
* @param Builder $query
*
* @return Builder
*/
public function build(Builder $query)
{
if ($this->page === null) {
return $query->whereNull('parent_id');
}
list($col, $direction) = $this->page->getChildOrderingPolicy();
return $query->where('parent_id', '=', $this->page->getId())->orderBy($col, $direction);
}
示例5: find
/**
* @param User $actor
* @param Builder $query
*/
public function find(User $actor, Builder $query)
{
if (!$actor->hasPermission('discussion.hide')) {
$query->where(function ($query) use($actor) {
$query->whereNull('discussions.hide_time')->where('comments_count', '>', 0)->orWhere('start_user_id', $actor->id);
$this->events->fire(new ScopeHiddenDiscussionVisibility($query, $actor, 'discussion.hide'));
});
}
}
示例6: newQuery
/**
* Overriding newQuery() to the custom PostBuilder with some intereting methods
*
* @param bool $excludeDeleted
* @return Corcel\PostBuilder
*/
public function newQuery($excludeDeleted = true)
{
$builder = new Builder($this->newBaseQueryBuilder());
$builder->setModel($this);
$builder->leftJoin('wp_term_taxonomy', 'wp_terms.term_id', '=', 'wp_term_taxonomy.term_id')->where('wp_term_taxonomy.taxonomy', '=', 'category')->select('wp_terms.*');
if ($excludeDeleted and $this->softDelete) {
$builder->whereNull($this->getQualifiedDeletedAtColumn());
}
return $builder;
}
示例7: scopeForModel
/**
* Constrain a query to an ability for a specific model.
*
* @param \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder $query
* @param \Illuminate\Database\Eloquent\Model $model
* @return void
*/
public function scopeForModel($query, Model $model)
{
$query->where(function ($query) use($model) {
$query->where('entity_type', $model->getMorphClass());
$query->where(function ($query) use($model) {
$query->whereNull('entity_id');
if ($model->exists) {
$query->orWhere('entity_id', $model->getKey());
}
});
});
}
示例8: scopeTaggedWith
/**
* @param Builder $builder
* @param Collection $tags
* @return Builder
*/
public function scopeTaggedWith(Builder $builder, Collection $tags)
{
/** @var MorphToMany $relation */
$relation = $this->tags();
$key = $this->getTable() . '.' . $this->getKeyName();
if ($tags->count()) {
$builder->join($relation->getTable(), function ($join) use($relation, $key, $tags) {
$join->on($relation->getForeignKey(), '=', $key);
$join->where($relation->getMorphType(), '=', $relation->getMorphClass());
$join->whereIn($relation->getOtherKey(), $tags->keys()->toArray());
});
} else {
$builder->whereNull($this->getTable());
}
return $builder;
}
示例9: apply
/**
* Aplicar.
*
* @param Builder $builder
* @param Model $model
*/
public function apply(Builder $builder, Model $model)
{
// Verificar se deve filtrar o inquilino
if (isset($model->multTenant) && $model->multTenant == true) {
// Verificar se esta logado
if (is_null(\Auth::id())) {
return;
}
// Verificar qual o inquilino informado
$inquilino_id = \Auth::user()->{Table::tenantField()};
if (is_null($inquilino_id)) {
$builder->whereNull(Table::tenantField());
} else {
$builder->where(Table::tenantField(), $inquilino_id);
}
}
}
示例10: scopeNotScheduled
/**
* Finds all non-scheduled incidents.
*
* @param \Illuminate\Database\Eloquent\Builder $query
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeNotScheduled(Builder $query)
{
return $query->where('status', '>', 0)->orWhere(function ($query) {
$query->where('status', 0)->where(function ($query) {
$query->whereNull('scheduled_at')->orWhere('scheduled_at', '<=', Carbon::now()->toDateTimeString());
});
});
}
示例11: scopeForModel
/**
* Constrain a query to an permission for a specific model.
*
* @param \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder $query
* @param \Illuminate\Database\Eloquent\Model|string $model
* @param bool $strict
* @return void
*/
public function scopeForModel($query, $model, $strict = false)
{
$model = is_string($model) ? new $model() : $model;
$query->where(function ($query) use($model, $strict) {
$query->where('entity_type', $model->getMorphClass());
$query->where(function ($query) use($model, $strict) {
// If the model does not exist, we want to search for blanket permissions
// that cover all instances of this model. If it does exist, we only
// want to find blanket permissions if we're not using strict mode.
if (!$model->exists || !$strict) {
$query->whereNull('entity_id');
}
if ($model->exists) {
$query->orWhere('entity_id', $model->getKey());
}
});
});
}
示例12: scopeGuests
/**
* Returns all the guest users.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeGuests(Builder $query)
{
return $query->whereNull('user_id');
}
示例13: generateNullConditionFromHasOneOrMany
private function generateNullConditionFromHasOneOrMany(HasOneOrMany $relation)
{
$this->query = $this->query->whereNull($relation->getForeignKey());
}
示例14: scopeParents
public function scopeParents(Builder $builder)
{
$builder->whereNull('parent_id');
}
示例15: whereNull
/**
* Add a whereNull to the query
*
* @param $field
* @return mixed
*/
public function whereNull($field)
{
$this->builder = $this->builder->whereNull($field);
return $this;
}