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


PHP Builder::whereNested方法代码示例

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


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

示例1: build

 public function build(Builder $query)
 {
     $text = $this->title;
     return $query->whereNested(function (QueryBuilder $query) use($text) {
         return $query->where('title', 'like', "%{$text}%")->orWhere('description', 'like', "%{$text}%");
     });
 }
开发者ID:boomcms,项目名称:boom-core,代码行数:7,代码来源:TitleContains.php

示例2: apply

 /**
  * @param \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder $query
  *
  * @return void
  */
 public function apply($query)
 {
     $query->where(function ($query) {
         $logic = $this->logic === static::LOGIC_AND ? 'and' : 'or';
         foreach ($this->criteria as $criteria) {
             $query->whereNested(function ($query) use($criteria) {
                 $criteria->apply($query);
             }, $logic);
         }
     });
 }
开发者ID:viniciusferreira,项目名称:laravel-repository,代码行数:16,代码来源:MultipleCriteria.php

示例3: buildWheres

 /**
  * @param Builder|QueryBuilder $queryBuilder
  * @param array $wheres
  * @param string $boolean
  */
 protected function buildWheres($queryBuilder, array $wheres, $boolean = 'and')
 {
     foreach ($wheres as $whereField => $where) {
         if (!isset($whereField) || !isset($where)) {
             continue;
         }
         $whereField = strtolower($whereField);
         // Nested OR where
         // Example: 'or' => ['foo' => 'bar', 'x => 'y']
         if ($whereField === 'or') {
             $queryBuilder->whereNested(function ($queryBuilder) use($where) {
                 $this->buildWheres($queryBuilder, $where, 'or');
             }, $boolean);
             continue;
         }
         // Nested AND where
         // Example: 'and' => ['foo' => 'bar', 'x => 'y']
         if ($whereField === 'and') {
             $queryBuilder->whereNested(function ($queryBuilder) use($where) {
                 $this->buildWheres($queryBuilder, $where, 'and');
             }, $boolean);
             continue;
         }
         // Operator is present on query
         // Example: 'foo' => ['like' => '%bar%']
         if (is_array($where)) {
             foreach ($where as $whereOperator => $whereValue) {
                 $whereOperator = $this->parseOperator($whereOperator);
                 $this->buildWhere($queryBuilder, $whereField, $whereOperator, $whereValue, $boolean);
             }
             continue;
         }
         // Operator is omitted on query, assumes '='
         // Example: 'foo' => 'bar'
         $whereOperator = is_array($where) ? array_keys($where)[0] : '=';
         $whereValue = is_array($where) ? $where[$whereOperator] : $where;
         $whereOperator = $this->parseOperator($whereOperator);
         $this->buildWhere($queryBuilder, $whereField, $whereOperator, $whereValue, $boolean);
     }
 }
开发者ID:williamoliveira,项目名称:eloquent-array-query-builder,代码行数:45,代码来源:ArrayBuilder.php


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