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


PHP Builder::whereRaw方法代碼示例

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


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

示例1: apply

 /**
  * @param Builder $builder
  * @param Model $model
  */
 public function apply(Builder $builder, Model $model)
 {
     if ($this->enabled === false) {
         return;
     }
     foreach ($this->getModelTenants($model) as $tenantColumn => $tenantId) {
         $builder->whereRaw($model->getTenantWhereClause($tenantColumn, $tenantId));
     }
 }
開發者ID:etiennemarais,項目名稱:legit,代碼行數:13,代碼來源:TenantScope.php

示例2: scopeWherePgJsonbKeysExist

 /**
  * Check if jsonb field has all or any of the keys/elements specified in $keys array
  * @param Builder $query
  * @param string $column
  * @param array $keys
  * @param string $has all|any
  * @return Builder
  */
 public function scopeWherePgJsonbKeysExist(Builder $query, $column, array $keys, $has = 'all')
 {
     $mark = '&';
     if ($has === 'any') {
         $mark = '|';
     }
     $keys = Helper::phpArrayToPostgresArray($keys);
     $column = Helper::nestedJsonColumn($column);
     return $query->whereRaw("{$column} \\?{$mark} ?", [$keys]);
 }
開發者ID:asmiarowski,項目名稱:laravel-postgres,代碼行數:18,代碼來源:PostgresJsonb.php

示例3: apply

 /**
  * Apply the scope to a given Eloquent query builder.
  *
  * @param Builder|\Illuminate\Database\Query\Builder $builder
  * @param Model|\Illuminate\Database\Query\Model     $model
  *
  * @return void
  */
 public function apply(Builder $builder, Model $model)
 {
     if (!$this->enabled) {
         return;
     }
     // Use whereRaw instead of where to avoid issues with bindings when removing
     foreach ($this->getModelTenants($model) as $tenantColumn => $tenantId) {
         $builder->whereRaw($model->getTenantWhereClause($tenantColumn, $tenantId));
     }
 }
開發者ID:BlueBayTravel,項目名稱:laravel-multi-tenant,代碼行數:18,代碼來源:TenantScope.php

示例4: createWhere

 /**
  * @param \Illuminate\Database\Eloquent\Builder $builder
  * @param \Illuminate\Database\Eloquent\Model $model
  */
 protected function createWhere(EloquentBuilder $builder, Eloquent $model)
 {
     if ($model->getOnlyTranslated() && $model->shouldFallback()) {
         $key = $model->getForeignKey();
         $primary = "{$this->i18nTable}.{$key}";
         $fallback = "{$this->i18nTable}_fallback.{$key}";
         $ifNull = $builder->getQuery()->compileIfNull($primary, $fallback);
         $builder->whereRaw("{$ifNull} is not null");
     }
 }
開發者ID:laraplus,項目名稱:translatable,代碼行數:14,代碼來源:TranslatableScope.php

示例5: apply

 /**
  * Apply the scope to a given Eloquent query builder.
  *
  * @param  \Illuminate\Database\Eloquent\Builder $builder
  * @throws TenantNotSetError
  * @return void
  */
 public function apply(Builder $builder, Model $model)
 {
     $this->refreshTenant();
     if ($this->disabled) {
         return;
     }
     if ($this->tenant_id === null) {
         throw new TenantNotSetError();
     }
     $builder->whereRaw("{$builder->getQuery()->from}.{$this->tenant_column} = {$this->tenant_id}");
 }
開發者ID:warksit,項目名稱:tenant,代碼行數:18,代碼來源:TenantScope.php

示例6: find

 /**
  * @param User $actor
  * @param Builder $query
  */
 public function find(User $actor, Builder $query)
 {
     if ($actor->cannot('viewDiscussions')) {
         $query->whereRaw('FALSE');
     } elseif (!$actor->hasPermission('discussion.hide')) {
         $query->where(function ($query) use($actor) {
             $query->whereNull('discussions.hide_time')->where('comments_count', '>', 0)->orWhere('start_user_id', $actor->id);
             $this->events->fire(new ScopeHiddenDiscussionVisibility($query, $actor, 'discussion.hide'));
         });
     }
 }
開發者ID:JoshyPHP,項目名稱:flarum-core,代碼行數:15,代碼來源:DiscussionPolicy.php

示例7: scopeWhereVisibleTo

 /**
  * Scope a query to only include records that are visible to a user.
  *
  * @param Builder $query
  * @param User $actor
  */
 public function scopeWhereVisibleTo(Builder $query, User $actor)
 {
     if (!app('flarum.forum')->can($actor, 'view')) {
         if ($this instanceof User) {
             $query->where('id', $actor->id);
         } else {
             $query->whereRaw('FALSE');
         }
     } else {
         event(new ScopeModelVisibility($this, $query, $actor));
     }
 }
開發者ID:redstarxz,項目名稱:flarumone,代碼行數:18,代碼來源:VisibleScope.php

示例8: getRelationQuery

 /**
  * @param EloquentBuilder $query
  * @param EloquentBuilder $parent
  * @param array $columns
  *
  * @return mixed
  */
 public function getRelationQuery(EloquentBuilder $query, EloquentBuilder $parent, $columns = ['*'])
 {
     $query->select($columns);
     $table = $query->getModel()->getTable();
     $query->from($table . ' as ' . ($hash = $this->getRelationCountHash()));
     $grammar = $query->getQuery()->getGrammar();
     $table = $grammar->wrapTable($table);
     $hash = $grammar->wrapTable($hash);
     $lft = $grammar->wrap($this->parent->getLftName());
     $rgt = $grammar->wrap($this->parent->getRgtName());
     return $query->whereRaw("{$hash}.{$lft} between {$table}.{$lft} + 1 and {$table}.{$rgt}");
 }
開發者ID:nutsdo,項目名稱:nong-store,代碼行數:19,代碼來源:DescendantsRelation.php

示例9: apply

 /**
  * Apply the scope to a given Eloquent query builder.
  *
  * @param  \Illuminate\Database\Eloquent\Builder $builder
  *
  * @throws Exceptions\TenantIdNotSetException
  * @return void
  */
 public function apply(Builder $builder)
 {
     if (is_null(self::getTenantId())) {
         if (self::$enabled) {
             throw new TenantIdNotSetException();
         }
         return;
     }
     /** @var \Illuminate\Database\Eloquent\Model|ScopedByTenant $model */
     $model = $builder->getModel();
     // Use whereRaw instead of where to avoid issues with bindings when removing
     $builder->whereRaw($model->getTenantWhereClause());
 }
開發者ID:warksit,項目名稱:laravel-multi-tenant,代碼行數:21,代碼來源:TenantScope.php

示例10: apply

 public function apply(Builder $builder, Model $model)
 {
     if (!$this->isEnabled($model)) {
         return;
     }
     $traces = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
     foreach ($traces as $trace) {
         // Find the first non-vendor-dir file in the backtrace
         if (isset($trace['file']) && !str_contains($trace['file'], DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR)) {
             $file = '"query.file" <> "' . $trace['file'] . '"';
             $line = '"query.line" <> "' . $trace['line'] . '"';
             return $builder->whereRaw($file)->whereRaw($line);
         }
     }
 }
開發者ID:fitztrev,項目名稱:query-tracer,代碼行數:15,代碼來源:QueryTracer.php

示例11: apply

 /**
  * @param Builder $builder
  * @param Model   $model
  */
 public function apply(Builder $builder, Model $model)
 {
     if (!Auth::guest() && Auth::user()->hasCountryRole()) {
         $country = Auth::user()->country;
         if ($builder->getModel()->getTable() == "activity_logs") {
             $builder->whereHas('contract', function ($q) use($country) {
                 $q->whereRaw("contracts.metadata->'country'->>'code' in (?)", $country);
             });
         } elseif ($builder->getModel()->getTable() == "contract_annotations") {
             $builder->whereHas('contract', function ($q) use($country) {
                 $q->whereRaw("contracts.metadata->'country'->>'code' in (?)", $country);
             });
         } else {
             $builder->whereRaw("contracts.metadata->'country'->>'code' in (?)", $country);
         }
     }
 }
開發者ID:sadhakbj,項目名稱:resourcecontracts.org,代碼行數:21,代碼來源:CountryScope.php

示例12: apply

 /**
  * Apply the scope to a given Eloquent query builder.
  * @param  \Illuminate\Database\Eloquent\Builder  $builder
  * @param  \Illuminate\Database\Eloquent\Model    $builder
  * @return void
  */
 public function apply(Builder $builder, Model $model)
 {
     $builder->whereRaw("level = {$this->level}");
 }
開發者ID:ruysu,項目名稱:laravel-core,代碼行數:10,代碼來源:LevelScope.php

示例13: scopeInIntegerSlot

 /**
  * Only retrieve files whose slots are integers.
  *
  * @param Builder $query
  * @return Builder
  */
 public function scopeInIntegerSlot(Builder $query)
 {
     return $query->whereRaw(sprintf('%s.slot REGEXP \'^[[:digit:]]+$\'', $query->getQuery()->from));
 }
開發者ID:atrauzzi,項目名稱:phperclip,代碼行數:10,代碼來源:Clipping.php

示例14: find

 /**
  * @param User $actor
  * @param Builder $query
  */
 public function find(User $actor, Builder $query)
 {
     if ($actor->cannot('viewDiscussions')) {
         $query->whereRaw('FALSE');
     }
 }
開發者ID:JoshyPHP,項目名稱:flarum-core,代碼行數:10,代碼來源:UserPolicy.php

示例15: scopeWherePgArrayOverlap

 /**
  * Where database array $column has any of the elements in $value
  * @param Builder $query
  * @param string $column
  * @param mixed $value
  * @return Builder
  */
 public function scopeWherePgArrayOverlap(Builder $query, $column, $value)
 {
     $value = self::mutateToPgArray((array) $value);
     return $query->whereRaw("{$column} && ?", [$value]);
 }
開發者ID:asmiarowski,項目名稱:laravel-postgres,代碼行數:12,代碼來源:PostgresArray.php


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