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


PHP Builder::whereIn方法代码示例

本文整理汇总了PHP中Illuminate\Database\Eloquent\Builder::whereIn方法的典型用法代码示例。如果您正苦于以下问题:PHP Builder::whereIn方法的具体用法?PHP Builder::whereIn怎么用?PHP Builder::whereIn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Database\Eloquent\Builder的用法示例。


在下文中一共展示了Builder::whereIn方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: scopeWithTag

 public static function scopeWithTag(Builder $query, $tags, $type = 'slug')
 {
     $tags = (new static())->prepareTags($tags);
     return $query->whereHas('tags', function ($query) use($type, $tags) {
         $query->whereIn($type, $tags);
     });
 }
开发者ID:phantomlight,项目名称:programme-chameleon,代码行数:7,代码来源:TaggableTrait.php

示例2: whereIn

 /**
  * Add a whereIn to the query
  *
  * @param  string $field
  * @param  array  $values
  * @param  bool   $order
  *
  * @return $this
  */
 public function whereIn($field, $values, $order = false)
 {
     $this->builder = $this->builder->whereIn($field, $values);
     if ($order) {
         $this->builder = $this->builder->orderByRaw(DB::raw("FIELD(" . $field . ", " . implode(',', $values) . ")"));
     }
     return $this;
 }
开发者ID:kodebyraaet,项目名称:pattern,代码行数:17,代码来源:BaseRepository.php

示例3: scopeInLog

 public function scopeInLog(Builder $query, ...$logNames) : Builder
 {
     if (is_array($logNames[0])) {
         $logNames = $logNames[0];
     }
     return $query->whereIn('log_name', $logNames);
 }
开发者ID:spatie,项目名称:laravel-activitylog,代码行数:7,代码来源:Activity.php

示例4: setIn

 /**
  * In
  *
  * @param $key
  * @param $value
  * @return $this
  */
 private function setIn($key, $value)
 {
     if (is_array($value)) {
         $this->query->whereIn($key, $value);
     }
     return $this;
 }
开发者ID:aginev,项目名称:search-filters,代码行数:14,代码来源:Filter.php

示例5: onQuerying

 /**
  * Fired just before querying
  * for table entries.
  *
  * @param Builder $query
  */
 public function onQuerying(Builder $query)
 {
     $uploaded = $this->getUploaded();
     $query->whereIn('id', $uploaded ?: [0]);
     $query->orderBy('updated_at', 'ASC');
     $query->orderBy('created_at', 'ASC');
 }
开发者ID:tobz-nz,项目名称:file-field_type,代码行数:13,代码来源:UploadTableBuilder.php

示例6: apply

 /**
  * Apply the scope to a given Eloquent query builder.
  *
  * @param  \Illuminate\Database\Eloquent\Builder  $builder
  * @return void
  */
 public function apply(Builder $builder, Model $model)
 {
     $subclassTypes = array_keys($model->getSingleTableTypeMap());
     if (!empty($subclassTypes)) {
         $builder->whereIn($model->getQualifiedSingleTableTypeColumn(), $subclassTypes);
     }
 }
开发者ID:phaza,项目名称:single-table-inheritance,代码行数:13,代码来源:SingleTableInheritanceScope.php

示例7: constrainWhereIsAll

 /**
  * Constrain the given users query by all provided roles.
  *
  * @param  \Illuminate\Database\Eloquent\Builder  $query
  * @param  string  $role
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function constrainWhereIsAll($query, $role)
 {
     $roles = array_slice(func_get_args(), 1);
     return $query->whereHas('roles', function ($query) use($roles) {
         $query->whereIn('name', $roles);
     }, '=', count($roles));
 }
开发者ID:jonagoldman,项目名称:bouncer,代码行数:14,代码来源:Roles.php

示例8: apply

 /**
  * Apply the scope to a given Eloquent query builder.
  *
  * @param  \Illuminate\Database\Eloquent\Builder  $builder
  * @param  \Illuminate\Database\Eloquent\Model  $model
  * @return void
  */
 public function apply(Builder $builder, Model $model)
 {
     if (isset($model->type_field) && isset($model->type)) {
         if (!is_array($model->type)) {
             $builder->where($model->type_field, $model->type);
         } else {
             $builder->whereIn($model->type_field, $model->type);
         }
     } elseif (isset($model->type)) {
         if (!is_array($model->type)) {
             $builder->where('type', $model->type);
         } else {
             $builder->whereIn('type', $model->type);
         }
     }
 }
开发者ID:ThunderID,项目名称:HRIS-API,代码行数:23,代码来源:TypeScope.php

示例9: deleteLimit

 /**
  *
  * Delete numbers of notifications equals
  * to the number passing as 2 parameter of
  * the current user
  *
  * @param $user_id    int
  * @param $entity
  * @param $number     int
  * @param $order      string
  * @return int
  * @throws \Exception
  */
 public function deleteLimit($user_id, $entity, $number, $order)
 {
     $notifications_ids = $this->notification->wherePolymorphic($user_id, $entity)->orderBy('id', $order)->select('id')->limit($number)->lists('id');
     if (count($notifications_ids) == 0) {
         return false;
     }
     return $this->notification->whereIn('id', $notifications_ids)->delete();
 }
开发者ID:naimkhalifa,项目名称:Notifynder,代码行数:21,代码来源:NotificationRepository.php

示例10: build

 public function build(Builder $query)
 {
     if (is_array($this->title)) {
         return $query->whereIn('title', $this->title);
     } else {
         return $query->where('title', '=', $this->title);
     }
 }
开发者ID:boomcms,项目名称:boom-core,代码行数:8,代码来源:Title.php

示例11: findAllBy

 public function findAllBy($attribute, $value, $columns = ['*'])
 {
     $this->newQuery();
     // Perform where in
     if (is_array($value)) {
         return $this->query->whereIn($attribute, $value)->get($columns);
     }
     return $this->query->where($attribute, '=', $value)->get($columns);
 }
开发者ID:sthWrong,项目名称:season5.co,代码行数:9,代码来源:AbstractRepository.php

示例12: applySimpleFilter

 /**
  * Apply simple filter
  *
  * @param Filter $filter
  */
 protected function applySimpleFilter(Filter $filter)
 {
     $value = (array) $filter->getValue();
     if (count($value) > 1) {
         $this->query->whereIn($filter->getField(), $value);
     } else {
         $this->query->where($filter->getField(), $filter->getOperator(), $value[0]);
     }
 }
开发者ID:mnabialek,项目名称:laravel-eloquent-filter,代码行数:14,代码来源:QueryFilter.php

示例13: build

 public function build(Builder $query)
 {
     $query->join('assets_tags', 'assets_tags.asset_id', '=', 'assets.id');
     if (is_array($this->tags)) {
         $query->whereIn('assets_tags.tag', $this->tags)->groupBy('tag')->having(DB::raw('count(distinct tag)'), '=', count($this->tags));
     } else {
         $query->where('assets_tags.tag', '=', $this->tags);
     }
     return $query;
 }
开发者ID:robbytaylor,项目名称:boom-core,代码行数:10,代码来源:Tag.php

示例14: apply

 /**
  * Apply the scope to a given Eloquent query builder.
  *
  * @param  \Illuminate\Database\Eloquent\Builder $builder
  * @param  \Illuminate\Database\Eloquent\Model $model
  *
  * @return void
  */
 public function apply(Builder $builder, Model $model)
 {
     $strict = isset($model::$strictModeration) ? $model::$strictModeration : config('moderation.strict');
     if ($strict) {
         $builder->where($model->getQualifiedStatusColumn(), '=', Status::APPROVED);
     } else {
         $builder->whereIn($model->getStatusColumn(), [Status::APPROVED, Status::PENDING]);
     }
     $this->extend($builder);
 }
开发者ID:gecche,项目名称:laravel-moderation,代码行数:18,代码来源:ModerationScope.php

示例15: applyLoggedInScope

 /**
  * Apply logged in scope.
  *
  * @param \Illuminate\Database\Eloquent\Builder  $query
  * @param \Gitamin\Models\User  $user
  *
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function applyLoggedInScope(Builder $query, User $user)
 {
     $isPrivate = function ($query) use($user) {
         $query->where('visibility_level', '=', self::VISIBILITY_PRIVATE)->where("{$this->tableName}.creator_id", '=', $user->id);
     };
     $whereVisible = function ($query) use($isPrivate) {
         $query->whereIn('visibility_level', [self::VISIBILITY_PUBLIC, self::VISIBILITY_LOGGED_IN])->orWhere($isPrivate);
     };
     return $query->where($whereVisible);
 }
开发者ID:xiaobailc,项目名称:Gitamin,代码行数:18,代码来源:VisibilityScope.php


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