當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Builder::whereNotNull方法代碼示例

本文整理匯總了PHP中Illuminate\Database\Eloquent\Builder::whereNotNull方法的典型用法代碼示例。如果您正苦於以下問題:PHP Builder::whereNotNull方法的具體用法?PHP Builder::whereNotNull怎麽用?PHP Builder::whereNotNull使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Database\Eloquent\Builder的用法示例。


在下文中一共展示了Builder::whereNotNull方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: apply

 /**
  * Apply the scope to a given Eloquent query builder.
  *
  * @param  \Illuminate\Database\Eloquent\Builder  $builder
  * @return void
  */
 public function apply(Builder $builder)
 {
     $model = $builder->getModel();
     $builder->whereNotNull($model->getQualifiedActivatedAtColumn());
     $builder->macro('withDeactivated', function (Builder $builder) {
         $this->remove($builder);
         return $builder;
     });
     $builder->macro('onlyDeactivated', function (Builder $builder) {
         $model = $builder->getModel();
         $this->remove($builder);
         $builder->getQuery()->whereNotNull($model->getQualifiedActivatedAtColumn());
         return $builder;
     });
     $builder->macro('deactivate', function (Builder $builder) {
         $model = $builder->getModel();
         $builder->withDeactivated();
         return $builder->update([$model->getActivatedAtColumn() => null]);
     });
     $builder->macro('activate', function (Builder $builder) {
         $model = $this->getModel();
         $query = $model->newQuery()->where($model->getKeyName(), $model->getKey());
         $model->{$model->getActivatedAtColumn()} = $time = $model->freshTimestamp();
         $query->update([$model->getActivatedAtColumn() => $model->fromDateTime($time)]);
     });
 }
開發者ID:niclasleonbock,項目名稱:eloquent-activatable,代碼行數:32,代碼來源:ActivatableScope.php

示例2: count

 /**
  * Returns the count for a countable parameter, given the query provided
  *
  * @param string                   $name
  * @param EloquentBuilder          $query
  * @param CountableFilterInterface $filter
  * @return array
  */
 public function count($name, $query, CountableFilterInterface $filter)
 {
     // if the columnname is not set, assume an id field based on a table name
     $columnName = empty($this->columnName) ? $name : $this->columnName;
     if (!$this->includeEmpty) {
         $query->whereNotNull($columnName);
     }
     return $query->select("{$columnName} AS {$this->columnAlias}", DB::raw("{$this->countRaw} AS {$this->countAlias}"))->groupBy($columnName)->pluck($this->countAlias, $this->columnAlias);
 }
開發者ID:czim,項目名稱:laravel-filter,代碼行數:17,代碼來源:SimpleDistinctValue.php

示例3: scopeAttached

 /**
  * Modifies the query to only include files attached to an clippable.
  *
  * @param Builder $query
  * @return Builder
  */
 public function scopeAttached(Builder $query)
 {
     return $query->whereNotNull('clippable_id')->whereNotNull('clippable_type');
 }
開發者ID:atrauzzi,項目名稱:phperclip,代碼行數:10,代碼來源:Clipping.php

示例4: scopeIsVerified

 /**
  * Scope verified subscribers.
  *
  * @param \Illuminate\Database\Eloquent\Builder $query
  *
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function scopeIsVerified(Builder $query)
 {
     return $query->whereNotNull('verified_at');
 }
開發者ID:uwm-appbrewery,項目名稱:Cachet,代碼行數:11,代碼來源:Subscriber.php

示例5: scopeWithDueDate

 /**
  * Scope a query to only include the jobs that have a due date.
  *
  * @param \Illuminate\Database\Eloquent\Builder $query
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function scopeWithDueDate($query)
 {
     return $query->whereNotNull('job_cards_orig_oc_date')->orWhere('job_cards_new_oc_date', '<>', null);
 }
開發者ID:buys-fran,項目名稱:mtech-mis,代碼行數:10,代碼來源:JobCard.php

示例6: scopeRegistered

 /**
  * Returns all the registered users.
  *
  * @param  \Illuminate\Database\Eloquent\Builder  $query
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function scopeRegistered(Builder $query)
 {
     return $query->whereNotNull('user_id')->with('user');
 }
開發者ID:umahatokula,項目名稱:academia,代碼行數:10,代碼來源:Session.php

示例7: scopeNear

 /**
  * Get groups near a another address.
  *
  * @param Builder $q
  * @param Address $address
  * @param null    $miles
  *
  * @return $this
  */
 public function scopeNear(Builder $q, Address $address, $miles = null)
 {
     if (is_null($miles)) {
         $miles = Config::get('biblebowl.groups.nearby');
     }
     return $q->active()->with(['address' => function ($q) use($miles, $address) {
         $q->whereNotNull($address->getLatColumn())->whereNotNull($address->getLngColumn())->within($miles, 'miles', $address->latitude, $address->longitude);
     }]);
 }
開發者ID:BibleBowl,項目名稱:account,代碼行數:18,代碼來源:Group.php

示例8: 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

示例9: whereNotNull

 /**
  * Add a whereNotNull to the query
  *
  * @param $field
  * @return mixed
  */
 public function whereNotNull($field)
 {
     $this->builder = $this->builder->whereNotNull($field);
     return $this;
 }
開發者ID:kodebyraaet,項目名稱:pattern,代碼行數:11,代碼來源:BaseRepository.php

示例10: scopeInactive

 /**
  * Query scope for inactive groups.
  */
 public function scopeInactive(Builder $query)
 {
     return $query->whereNotNull($this->getInactiveColumn());
 }
開發者ID:BibleBowl,項目名稱:account,代碼行數:7,代碼來源:CanDeactivate.php

示例11: 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)
 {
     $builder->whereNotNull('published_at');
     $this->extend($builder);
 }
開發者ID:wunderfactory,項目名稱:weinform,代碼行數:12,代碼來源:PublishedScope.php

示例12: setNotNull

 /**
  * NotNull
  *
  * @param $key
  * @param $value
  * @return $this
  */
 private function setNotNull($key, $value)
 {
     $this->query->whereNotNull($key, $value);
     return $this;
 }
開發者ID:aginev,項目名稱:search-filters,代碼行數:12,代碼來源:Filter.php

示例13: scopeRead

 public function scopeRead(Builder $query)
 {
     $query->whereNotNull('read_at');
 }
開發者ID:gez-studio,項目名稱:gez-mall,代碼行數:4,代碼來源:Notification.php

示例14: scopeLoggedInUsers

 /**
  * Returns all the registered users.
  *
  * @param  \Illuminate\Database\Eloquent\Builder $query
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function scopeLoggedInUsers($query)
 {
     return $query->whereNotNull('user_id')->with('user');
 }
開發者ID:linhntaim,項目名稱:katniss,代碼行數:10,代碼來源:UserSession.php

示例15: apply

 /**
  * Applies parameter filtering for a given query
  *
  * @param string          $name
  * @param mixed           $value
  * @param EloquentBuilder $query
  * @param FilterInterface $filter
  * @return EloquentBuilder
  */
 public function apply($name, $value, $query, FilterInterface $filter)
 {
     $column = (!empty($this->table) ? $this->table . '.' : null) . (!empty($this->column) ? $this->column : $name);
     return $query->whereNotNull($column)->where($column, '!=', '');
 }
開發者ID:czim,項目名稱:laravel-filter,代碼行數:14,代碼來源:NotEmpty.php


注:本文中的Illuminate\Database\Eloquent\Builder::whereNotNull方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。