当前位置: 首页>>代码示例>>PHP>>正文


PHP Builder::has方法代码示例

本文整理汇总了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');
 }
开发者ID:kolexndr,项目名称:mustard,代码行数:11,代码来源:User.php

示例2: scopeTranslated

 /**
  * @param Builder $builder
  * @return Builder|static
  */
 public function scopeTranslated(Builder $builder)
 {
     return $builder->has('translations');
 }
开发者ID:jaffle-be,项目名称:framework,代码行数:8,代码来源:Translatable.php

示例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);
 }
开发者ID:cviebrock,项目名称:eloquent-taggable,代码行数:11,代码来源:Taggable.php

示例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);
     });
 }
开发者ID:draperstudio,项目名称:laravel-taggable,代码行数:11,代码来源:HasTagsTrait.php

示例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);
 }
开发者ID:larrytech,项目名称:auth,代码行数:10,代码来源:Role.php

示例6: scopeActive

 public function scopeActive(Builder $query)
 {
     $query->has('attributeOptions');
 }
开发者ID:gez-studio,项目名称:gez-mall,代码行数:4,代码来源:AttributeGroup.php

示例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);
 }
开发者ID:kolexndr,项目名称:mustard,代码行数:11,代码来源:Category.php

示例8: apply

 public function apply(Builder $builder, Model $model)
 {
     $builder->has('article');
     $this->addWithDrafts($builder);
 }
开发者ID:ruly1992,项目名称:elearning,代码行数:5,代码来源:HasArticleScope.php

示例9: applyToQuery

 /**
  * @param Builder $model
  * @return mixed
  */
 public function applyToQuery($model)
 {
     return $model->has($this->relation, $this->operator, $this->count, $this->boolean, $this->callback);
 }
开发者ID:czim,项目名称:laravel-repository,代码行数:8,代码来源:Has.php

示例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;
 }
开发者ID:sedp-mis,项目名称:base-repository,代码行数:16,代码来源:BaseRepositoryEloquent.php

示例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');
     }
 }
开发者ID:jwdeitch,项目名称:flarum-ext-tags,代码行数:16,代码来源:DiscussionPolicy.php

示例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');
 }
开发者ID:apolune,项目名称:account,代码行数:10,代码来源:Player.php

示例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());
     });
 }
开发者ID:ipunkt,项目名称:laravel-notify,代码行数:17,代码来源:Notification.php

示例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;
 }
开发者ID:Kodebyraaet,项目名称:pattern,代码行数:14,代码来源:BaseRepository.php

示例15: scopeTranslated

 /**
  * @param \Illuminate\Database\Eloquent\Builder $query
  *
  * @return \Illuminate\Database\Eloquent\Builder|static
  */
 public function scopeTranslated(Builder $query)
 {
     return $query->has('translations');
 }
开发者ID:jooorooo,项目名称:multi-language,代码行数:9,代码来源:Translatable.php


注:本文中的Illuminate\Database\Eloquent\Builder::has方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。