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


PHP Builder::whereIn方法代码示例

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


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

示例1: scopeNewestGrouped

 /**
  *
  *
  * @param Builder $query
  * @return Builder
  */
 public function scopeNewestGrouped($query)
 {
     // @todo: find a better way of doing this
     $newest = \DB::select("select max(id) as id from mail_statistics group by service_message_id");
     $newest = collect($newest)->pluck('id');
     return $query->whereIn('id', $newest->toArray())->newest();
 }
开发者ID:bitsoflove,项目名称:mailstats,代码行数:13,代码来源:MailStatistic.php

示例2: scopeFindByUuid

 /**
  * Method returns models geted by uuid
  * @param  Builder $query
  * @param  array|tring $uuid  uuid or list of uuids
  * @return Collection|Model Single model or collection of models
  */
 public function scopeFindByUuid($query, $uuid)
 {
     if (!is_array($uuid)) {
         if (!Uuid::isValid($uuid)) {
             throw (new ModelNotFoundException())->setModel(get_class($this));
         }
         return $query->where('uuid', $uuid)->first();
     } elseif (is_array($uuid)) {
         array_map(function ($element) {
             if (!Uuid::isValid($element)) {
                 throw (new ModelNotFoundException())->setModel(get_class($this));
             }
         }, $uuid);
         return $query->whereIn('uuid', $uuid)->get();
     }
 }
开发者ID:beautycoding,项目名称:modelutils,代码行数:22,代码来源:UuidModel.php

示例3: scopeWhereCategoryIs

 /**
  * @param string $category
  * @return Builder
  */
 public function scopeWhereCategoryIs(Builder $q, $category)
 {
     //aliases
     if ($category == 'contorni') {
         $category = 'Verdure, ortaggi e contorni';
     } elseif ($category == 'primi') {
         $category = 'Primi Piatti';
     } elseif ($category == 'secondi') {
         $category = ['Secondi di carne', 'Secondi di pesce'];
     }
     //dd($category);
     if (is_array($category)) {
         return $q->whereIn('category', $category);
     } else {
         return $q->where('category', '=', $category);
     }
 }
开发者ID:bonaccorsop,项目名称:JambonOrders,代码行数:21,代码来源:Product.php

示例4: scopeOfLevel

 /**
  * Filter results by a user level
  * @param  Builder $query
  * @return void
  */
 public function scopeOfLevel($query)
 {
     $args = func_get_args();
     $levels = array_splice($args, 1);
     $query->whereIn('level', $levels);
 }
开发者ID:ruysu,项目名称:laravel-core,代码行数:11,代码来源:User.php

示例5: manyMany

 private function manyMany()
 {
     $db = Config::get('database.' . $this->link_config);
     $db['connection'] = $this->link_config;
     $connection = Connection::get($db);
     $builder = new Builder($connection, $db, $this->link_table, $this->link_primary_key, null);
     //$child_list = $builder->whereIn($this->parent_column, $this->parent_list)->lists($this->child_column);
     $child_list = $builder->whereIn($this->parent_column, $this->parent_list)->get();
     $children = array();
     foreach ($child_list as $child) {
         $children[] = $child->{$this->child_column};
     }
     $child = $this->child;
     $return = $child::whereIn($this->child_column, $children)->get();
     if (count($this->parent_list) <= 1) {
         return $return;
     }
     foreach ($this->collection as &$item) {
         $collection = array();
         foreach ($child_list as $link) {
             if ($item->{$this->parent_column} == $link->{$this->parent_column}) {
                 foreach ($return as $child) {
                     if ($link->{$this->child_column} == $child->{$this->child_column}) {
                         $collection[] = $child;
                     }
                 }
             }
         }
         $item->{$this->function} = new \Frame\Collection($collection);
     }
 }
开发者ID:jasonmilli,项目名称:FrameWork2,代码行数:31,代码来源:with.php

示例6: metaQueryClause

 /**
  * @param  array   $queries  {
  *
  * @type string    $relation Optional. The MySQL keyword used to join the clauses of the query. Accepts 'AND', Or
  *       'OR'. Default 'AND'.
  *
  * @type array {
  * @type string    $key      Meta key to filter by.
  * @type string    $value    Meta value to filter by.
  * @type string    $compare  MySQL operator used for comparing the $value. Accepts '=',
  *                               '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN',
  *                               'BETWEEN', 'NOT BETWEEN', 'REGEXP', 'NOT REGEXP', or 'RLIKE'.
  *                               Default is '='
  *             }
  * }
  *
  * @param  Builder $q
  * @param  int     $depth
  */
 public function metaQueryClause($queries, &$q, $depth = 0)
 {
     $i = 0;
     foreach ($queries as $key => $query) {
         if ('relation' === $key) {
             //if relation were found we shall skip to the next iteration
             continue;
         } else {
             if (isset($query['key'])) {
                 // That happens when a non-nested query found on the first iteration
                 // in that case we the clause should be AND
                 $relation = 0 === $i ? 'AND' : $queries['relation'];
                 $q->where(function ($q) use($query) {
                     if (isset($query['key'])) {
                         $q->where('meta_key', '=', $query['key']);
                     }
                     if (isset($query['value'])) {
                         if (isset($query['compare'])) {
                             switch (strtolower($query['compare'])) {
                                 case 'between':
                                     $q->whereBetween('meta_value', $query['value']);
                                     break;
                                 case 'not between':
                                     $q->whereNotBetween('meta_value', $query['value']);
                                     break;
                                 case 'in':
                                     $q->whereIn('meta_value', $query['value']);
                                     break;
                                 case 'not in':
                                     $q->whereNotIn('meta_value', $query['value']);
                                     break;
                                 case 'is null':
                                     $q->whereIsNull('meta_value');
                                     break;
                                 case 'is not null':
                                     $q->whereIsNotNull('meta_value');
                                     break;
                                 default:
                                     $q->where('meta_value', $query['compare'], $query['value']);
                             }
                         } else {
                             $q->where('meta_value', '=', $query['value']);
                         }
                     }
                 }, null, null, $relation);
             } else {
                 if (is_array($query)) {
                     $depth = $depth + 1;
                     // If we're going recursive for the first iterate we shall make the relation AND by default
                     // else we should use the provided relation
                     $relation = 1 === $depth && 0 === $i ? 'AND' : $queries['relation'];
                     $q->where(function ($q) use($query, $depth) {
                         $this->metaQueryClause($query, $q, $depth);
                     }, null, null, $relation);
                 } else {
                     continue;
                 }
             }
         }
         $i++;
     }
 }
开发者ID:puresolcom,项目名称:polyether,代码行数:81,代码来源:MetaQuery.php

示例7: scopeWithIds

 /**
  * Exclude IDs that are not in a given array
  * @param  Builder $query
  * @param  array  $ids
  * @return void
  */
 public function scopeWithIds($query, array $ids)
 {
     $query->whereIn($this->getKeyName(), $ids);
 }
开发者ID:ruysu,项目名称:laravel-core,代码行数:10,代码来源:Model.php


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