本文整理汇总了PHP中Illuminate\Database\Eloquent\Builder::has方法的典型用法代码示例。如果您正苦于以下问题:PHP Builder::has方法的具体用法?PHP Builder::has怎么用?PHP Builder::has使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Eloquent\Builder
的用法示例。
在下文中一共展示了Builder::has方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: scopeSellers
/**
* Scope of sellers.
*
* @param \Illuminate\Database\Eloquent\Builder $query
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeSellers($query)
{
return $query->has('items');
}
示例2: scopeTranslated
/**
* @param Builder $builder
* @return Builder|static
*/
public function scopeTranslated(Builder $builder)
{
return $builder->has('translations');
}
示例3: scopeWithoutTags
/**
* Scope for a Model that doesn't have any tags.
*
* @param \Illuminate\Database\Eloquent\Builder $query
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeWithoutTags(Builder $query)
{
return $query->has('tags', '=', 0);
}
示例4: scopeWithAnyTags
public function scopeWithAnyTags(Builder $query, $tags = [])
{
$tags = Util::buildTagArray($tags);
if (empty($tags)) {
return $query->has('tags');
}
$slug = array_map([S::class, 'slugify'], $tags);
return $query->whereHas('tags', function ($q) use($slug) {
$q->whereIn('slug', $slug);
});
}
示例5: scopeInactive
/**
* Gets the roles with no users.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeInactive($query)
{
return $query->has('users', '<', 1);
}
示例6: scopeActive
public function scopeActive(Builder $query)
{
$query->has('attributeOptions');
}
示例7: scopeLeaves
/**
* Scope of categories with no children.
*
* @param \Illuminate\Database\Eloquent\Builder $query
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeLeaves($query)
{
return $query->has('children', 0);
}
示例8: apply
public function apply(Builder $builder, Model $model)
{
$builder->has('article');
$this->addWithDrafts($builder);
}
示例9: applyToQuery
/**
* @param Builder $model
* @return mixed
*/
public function applyToQuery($model)
{
return $model->has($this->relation, $this->operator, $this->count, $this->boolean, $this->callback);
}
示例10: queryHasRelations
/**
* Query has relations.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param array $hasRelations
* @return \Illuminate\Database\Eloquent\Builder
*/
protected function queryHasRelations($query, $hasRelations = [])
{
$hasRelations = $hasRelations ?: $this->hasRelations;
foreach ($hasRelations as $relation => $operatorCount) {
list($operator, $count) = $operatorCount;
$query->has($relation, $operator, $count);
}
return $query;
}
示例11: find
/**
* @param User $actor
* @param Builder $query
*/
public function find(User $actor, Builder $query)
{
// Hide discussions which have tags that the user is not allowed to see.
$query->whereNotExists(function ($query) use($actor) {
return $query->select(new Expression(1))->from('discussions_tags')->whereIn('tag_id', Tag::getIdsWhereCannot($actor, 'viewDiscussions'))->where('discussions.id', new Expression('discussion_id'));
});
// Hide discussions with no tags if the user doesn't have that global
// permission.
if (!$actor->hasPermission('viewDiscussions')) {
$query->has('tags');
}
}
示例12: scopeOnline
/**
* Scope a query to only include online players.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeOnline($query)
{
return $query->has('playerOnline');
}
示例13: scopeForUser
/**
* @param Builder $query
* @param UserInterface $user
* @return Builder
*/
public function scopeForUser(Builder $query, UserInterface $user = null)
{
if ($user === null && $this->user !== null) {
$user = $this->user;
}
if ($user === null) {
return $query->has('activities');
}
return $query->whereHas('activities', function ($q) use($user) {
$q->where('user_id', '=', $user->getAuthIdentifier());
});
}
示例14: has
/**
* Query wether or not the relationship is empty of now.
*
* @param $relation
* @param string $operator
* @param int $count
*
* @return $this
*/
public function has($relation, $operator = '>=', $count = 1)
{
$this->builder = $this->builder->has($relation, $operator, $count);
return $this;
}
示例15: scopeTranslated
/**
* @param \Illuminate\Database\Eloquent\Builder $query
*
* @return \Illuminate\Database\Eloquent\Builder|static
*/
public function scopeTranslated(Builder $query)
{
return $query->has('translations');
}