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


PHP Builder::whereNotIn方法代码示例

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


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

示例1: setNotIn

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

示例2: __call

 /**
  * @param $method
  * @param $parameters
  * @return Collection
  * @throws \Exception
  *
  * sets cache key if derived class method call
  * derived classes methods (like 'featured') are to be used as 'getFeatured'
  */
 public function __call($method, $parameters)
 {
     $realMethod = lcfirst(substr($method, 3));
     if (!method_exists($this, $realMethod)) {
         throw new \Exception("Method does not exist - " . $method);
     }
     if ($this->cache) {
         $this->cacheKey = ($this->onlyVisible ? '-' : '+') . ($this->onlyAuthored ? '-' : '+') . $this->baseName . ".{$realMethod}[" . serialize($parameters) . "]" . "\\{" . serialize($this->filters) . "\\}" . "<" . implode(',', $this->excludes) . ">";
         if ($this->limit) {
             $this->cacheKey .= "|{$this->limit}|";
         }
         if ($this->paginate) {
             $this->cacheKey .= 'p=' . (Paginator::resolveCurrentPage() ?: 1) . "&pp=" . $this->perPage;
         }
         if ($this->closure) {
             $this->cacheKey .= "{{$this->keyFragment}}";
         }
         if ($cache = Cache::get($this->cacheKey)) {
             $this->clearFilters();
             if ($this->appendExcludes) {
                 $this->excludes = array_merge($this->excludes, $cache->lists($this->identifier)->all());
                 $this->appendExcludes = false;
             }
             return $cache === 'null' ? null : $cache;
         }
     }
     $this->model = new $this->modelClass();
     $table = $this->model->getTable();
     $this->model = $this->model->newQuery();
     $this->model->select("{$table}.*");
     $this->model = $this->model->whereNotIn($table . '.' . $this->identifier, $this->excludes);
     $this->prepare($this->model);
     $this->filter($this->model, $this->filters);
     if ($this->onlyVisible) {
         $this->filterVisible($this->model);
     }
     if ($this->onlyAuthored) {
         $this->filterAuthored($this->model);
     }
     if ($this->limit) {
         $this->model->take($this->limit);
     }
     array_unshift($parameters, $this->model);
     call_user_func_array(array($this, $realMethod), $parameters);
     if ($this->closure) {
         $closure = $this->closure;
         $closure($this->model);
     }
     $result = $this->get();
     if ($this->appendExcludes) {
         $this->excludes = array_merge($this->excludes, $result->lists($this->identifier)->all());
         $this->appendExcludes = false;
     }
     $this->clearFilters();
     return $result;
 }
开发者ID:pointer-ba,项目名称:bundle,代码行数:65,代码来源:Repository.php

示例3: save

 /**
  * Store settings in the database.
  */
 public function save()
 {
     if ($this->unsaved) {
         $all = $this->getData();
         $data = array_dot($all);
         foreach ($data as $key => $value) {
             $this->options->updateOrCreate(compact('key'), compact('key', 'value'));
         }
         $this->options->whereNotIn('key', array_keys($data))->delete();
         $this->unsaved = false;
     }
 }
开发者ID:vluzrmos,项目名称:eloquent-settings,代码行数:15,代码来源:Setting.php

示例4: wherePermission

 /**
  *
  * @param \Illuminate\Database\Eloquent\Builder $builder        	
  * @param AclPermission $permission        	
  * @param string $field        	
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function wherePermission($builder, AclPermission $permission, $field = null)
 {
     if (!$field) {
         $field = $this->getAclKey();
     }
     if ($permission->allowed && !$permission->values) {
         return $builder;
     }
     if ($permission->allowed) {
         $builder->whereIn($this->getTable() . '.' . $field, $permission->values);
         return $builder;
     }
     if ($permission->values) {
         $builder->whereNotIn($this->getTable() . '.' . $field, $permission->values);
         return $builder;
     }
     throw new NoPermissionsException("No perrmision to " . $permission->resource);
     // return $builder->whereRaw('1 = 0');
 }
开发者ID:volicon,项目名称:laravel-acl-rbac,代码行数:26,代码来源:AclModel.php

示例5: apply

 /**
  * Applies constraint to query.
  *
  * @param Builder $builder query builder
  * @param string  $field   field name
  */
 public function apply(Builder $builder, $field)
 {
     if (strpos($field, ':') !== false) {
         list($model, $column) = explode(':', $field);
         $model = explode('_', $model);
         for ($i = 1; $i < count($model); $i++) {
             $model[$i] = ucfirst($model[$i]);
         }
         $model = implode($model);
         $field = str_replace(':', '.', $field);
         $builder->whereHas($model, function ($query) use($field) {
             $this->apply($query, $field);
         });
     } elseif ($this->operator == Constraint::OPERATOR_IN) {
         $builder->whereIn($field, $this->value);
     } elseif ($this->operator == Constraint::OPERATOR_NOT_IN) {
         $builder->whereNotIn($field, $this->value);
     } else {
         $builder->where($field, $this->operator, $this->value);
     }
 }
开发者ID:remipdt,项目名称:searchable,代码行数:27,代码来源:Constraint.php

示例6: find

 /**
  * @param User $actor
  * @param Builder $query
  */
 public function find(User $actor, Builder $query)
 {
     $query->whereNotIn('id', Tag::getIdsWhereCannot($actor, 'viewDiscussions'));
 }
开发者ID:jwdeitch,项目名称:flarum-ext-tags,代码行数:8,代码来源:TagPolicy.php

示例7: apply

 /**
  * @param Builder $where
  * @param array   $filters
  * @param string  $boolean
  */
 protected static function apply(Builder $where, array $filters, $boolean)
 {
     foreach ($filters as $filterName => $valuePair) {
         foreach ($valuePair as $key => $value) {
             if (is_array($value) && count($value) > 0) {
                 $value = array_values($value);
                 if (count($value[0]) > 1) {
                     switch ($filterName) {
                         case BaseFilter::RANGES:
                             $where->whereBetween($key, [$value[0][0], $value[0][1]], $boolean);
                             break;
                         case BaseFilter::NOT_RANGES:
                             $where->whereNotBetween($key, [$value[0][0], $value[0][1]], $boolean);
                             break;
                     }
                 } else {
                     switch ($filterName) {
                         case BaseFilter::GROUP:
                             $where->whereIn($key, $value, $boolean);
                             break;
                         case BaseFilter::NOT_GROUP:
                             $where->whereNotIn($key, $value, $boolean);
                             break;
                     }
                 }
             }
             $value = (array) $value;
             $value = array_shift($value);
             switch ($filterName) {
                 case BaseFilter::GREATER_THAN_OR_EQUAL:
                     $where->where($key, '>=', $value, $boolean);
                     break;
                 case BaseFilter::GREATER_THAN:
                     $where->where($key, '>', $value, $boolean);
                     break;
                 case BaseFilter::LESS_THAN_OR_EQUAL:
                     $where->where($key, '<=', $value, $boolean);
                     break;
                 case BaseFilter::LESS_THAN:
                     $where->where($key, '<', $value, $boolean);
                     break;
                 case BaseFilter::CONTAINS:
                     $where->where($key, 'LIKE', '%' . $value . '%', $boolean);
                     break;
                 case BaseFilter::NOT_CONTAINS:
                     $where->where($key, 'NOT LIKE', '%' . $value . '%', $boolean);
                     break;
                 case BaseFilter::STARTS_WITH:
                     $where->where($key, 'LIKE', $value . '%', $boolean);
                     break;
                 case BaseFilter::ENDS_WITH:
                     $where->where($key, 'LIKE', '%' . $value, $boolean);
                     break;
                 case BaseFilter::EQUALS:
                     $where->where($key, '=', $value, $boolean);
                     break;
                 case BaseFilter::NOT_EQUAL:
                     $where->where($key, '!=', $value, $boolean);
                     break;
             }
         }
     }
 }
开发者ID:LaravelRepository,项目名称:eloquent-repository,代码行数:68,代码来源:EloquentFilter.php

示例8: applyFilter

 public function applyFilter(Filter $filter, $operator, array $params)
 {
     $column = $filter->getField();
     $sqlLikeEscapes = ['%' => '\\%', '_' => '\\_'];
     switch ($operator) {
         // Zero-parameter operators
         case 'empty':
             $this->query->where(function ($query) use($column) {
                 $query->whereIn($column, ['', 0])->orWhereNull($column);
             });
             break;
         case 'not-empty':
             $this->query->where(function ($query) use($column) {
                 $query->whereNotIn($column, ['', 0])->whereNotNull($column);
             });
             break;
             // Single-parameter operators
         // Single-parameter operators
         case 'eq':
             $this->query->where($column, $params[0]);
             break;
         case 'ne':
             $this->query->where(function ($query) use($column, $params) {
                 $query->where($column, '!=', $params[0])->orWhereNull($column);
             });
             break;
         case 'lt':
             $this->query->where($column, '<', $params[0]);
             break;
         case 'gt':
             $this->query->where($column, '>', $params[0]);
             break;
         case 'lte':
             $this->query->where($column, '<=', $params[0]);
             break;
         case 'gte':
             $this->query->where($column, '>=', $params[0]);
             break;
         case 'starts-with':
             $this->query->where($column, 'LIKE', strtr($params[0], $sqlLikeEscapes) . '%');
             break;
         case 'ends-with':
             $this->query->where($column, 'LIKE', '%' . strtr($params[0], $sqlLikeEscapes));
             break;
         case 'contains':
             $this->query->where($column, 'LIKE', '%' . strtr($params[0], $sqlLikeEscapes) . '%');
             break;
         case 'not-starts-with':
             $this->query->where(function ($query) use($column, $params, $sqlLikeEscapes) {
                 $query->where($column, 'NOT LIKE', strtr($params[0], $sqlLikeEscapes) . '%')->orWhereNull($column);
             });
             break;
         case 'not-ends-with':
             $this->query->where(function ($query) use($column, $params, $sqlLikeEscapes) {
                 $query->where($column, 'NOT LIKE', '%' . strtr($params[0], $sqlLikeEscapes))->orWhereNull($column);
             });
             break;
         case 'not-contains':
             $this->query->where(function ($query) use($column, $params, $sqlLikeEscapes) {
                 $query->where($column, 'NOT LIKE', '%' . strtr($params[0], $sqlLikeEscapes) . '%')->orWhereNull($column);
             });
             break;
             // Dual-parameter operators
         // Dual-parameter operators
         case 'between':
             $this->query->whereBetween($column, $params);
             break;
         case 'not-between':
             $this->query->where(function ($query) use($column, $params, $sqlLikeEscapes) {
                 $query->whereNotBetween($column, $params)->orWhereNull($column);
             });
             break;
             // Unlimited-parameter operators
         // Unlimited-parameter operators
         case 'in':
             $this->query->whereIn($column, $params);
             break;
         case 'not-in':
             $this->query->whereNotIn($column, $params);
             break;
     }
     return $this;
 }
开发者ID:nhusby,项目名称:mason-laravel,代码行数:83,代码来源:EloquentContainer.php

示例9: scopeNotCategoryGroup

 /**
  * Filter by Not Category Group
  *
  * @param  \Illuminate\Database\Eloquent\Builder $query
  * @param  dynamic  string                       $groupId
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function scopeNotCategoryGroup(Builder $query, $groupId)
 {
     $groupIds = array_slice(func_get_args(), 1);
     return $query->whereNotIn('categories.group_id', $groupIds);
 }
开发者ID:khaliqgant,项目名称:Deep,代码行数:12,代码来源:Category.php

示例10: queryFilters

 /**
  * Query filters.
  *
  * @param  \Illuminate\Database\Eloquent\Builder $query
  * @return \Illuminate\Database\Eloquent\Builder
  */
 protected function queryFilters($query, $filters = [])
 {
     $filters = $filters ?: $this->filters;
     foreach ($filters as $key => $filter) {
         foreach ($filter as $operator => $values) {
             $values = is_array($values) ? $values : [$values];
             $operator = is_numeric($operator) ? '=' : $operator;
             if ($operator == '=') {
                 $query->whereIn($key, $values);
             } elseif ($operator == '!=') {
                 $query->whereNotIn($key, $values);
             } elseif ($operator == 'null') {
                 $query->whereNull($key);
             } elseif ($operator == 'not_null') {
                 $query->whereNotNull($key);
             } else {
                 $query->where($key, $operator, head($values));
             }
         }
     }
     return $query;
 }
开发者ID:sedp-mis,项目名称:base-repository,代码行数:28,代码来源:BaseRepositoryEloquent.php

示例11: scopeBut

 /**
  * @param Builder $builder
  * @param Collection $pages
  */
 public function scopeBut(Builder $builder, Collection $pages)
 {
     if ($pages->count() > 0) {
         $builder->whereNotIn($this->getKeyName(), $pages->lists($this->getKeyName())->toArray());
     }
 }
开发者ID:jaffle-be,项目名称:framework,代码行数:10,代码来源:ModuleRoute.php

示例12: applyOperation

 /**
  * Append where for a Quri operation
  *
  * @param Builder $builder
  * @param Operation $operation
  * @param $andOr
  * @return Builder
  * @throws ValidationException
  */
 public function applyOperation($builder, Operation $operation, $andOr)
 {
     $fieldName = $this->getRealFieldName($operation->fieldName());
     switch ($operation->operator()) {
         case "eq":
             $symbol = "=";
             break;
         case "neq":
             $symbol = "!=";
             break;
         case "gt":
             $symbol = ">";
             break;
         case "lt":
             $symbol = "<";
             break;
         case "gte":
             $symbol = ">=";
             break;
         case "lte":
             $symbol = "<=";
             break;
         case "like":
             $symbol = "like";
             break;
         case "between":
             return $builder->whereBetween($fieldName, $operation->values(), $andOr);
         case "in":
             return $builder->whereIn($fieldName, $operation->values(), $andOr);
         case "nin":
             return $builder->whereNotIn($fieldName, $operation->values(), $andOr);
         default:
             throw new ValidationException("QURI string could not be parsed. Operator '{$operation->operator()}' not supported");
     }
     return $builder->where($fieldName, $symbol, $operation->firstValue(), $andOr);
 }
开发者ID:theHarvester,项目名称:QURI-Laravel,代码行数:45,代码来源:QuriRequest.php

示例13: scopeNotStatus

 /**
  * Filter by Entry Status
  *
  * @param  \Illuminate\Database\Eloquent\Builder $query
  * @param  dynamic  string                       $status
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function scopeNotStatus(Builder $query, $status)
 {
     $statuses = is_array($status) ? $status : array_slice(func_get_args(), 1);
     return $query->whereNotIn('channel_titles.status', $statuses);
 }
开发者ID:khaliqgant,项目名称:Deep,代码行数:12,代码来源:Title.php

示例14: _query

 /**
  * @param Builder $query
  * @param string  $field
  * @param string  $condition
  */
 protected function _query(Builder $query, $field, $condition = 'and')
 {
     $query->whereNotIn($field, $this->getValue(), $condition);
 }
开发者ID:KodiComponents,项目名称:module-datasource,代码行数:9,代码来源:NotInOperator.php

示例15: filterBySearchTerm

 /**
  * Filters a relationship options query by a search term
  *
  * @param mixed										$term
  * @param \Illuminate\Database\Query\Builder		$query
  * @param \Frozennode\Administrator\Fields\Field	$fieldObject
  * @param array										$selectedItems
  * @param string									$relatedKeyTable
  */
 public function filterBySearchTerm($term, EloquentBuilder &$query, Field $fieldObject, array $selectedItems, $relatedKeyTable)
 {
     if ($term) {
         $query->where(function ($query) use($term, $fieldObject) {
             foreach ($fieldObject->getOption('search_fields') as $search) {
                 $query->orWhere($this->db->raw($search), 'LIKE', '%' . $term . '%');
             }
         });
         //exclude the currently-selected items if there are any
         if (count($selectedItems)) {
             $query->whereNotIn($relatedKeyTable, $selectedItems);
         }
         //set up the limits
         $query->take($fieldObject->getOption('num_options') + count($selectedItems));
     }
 }
开发者ID:dmitriyuch,项目名称:Laravel-Administrator,代码行数:25,代码来源:Factory.php


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