当前位置: 首页>>代码示例>>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;未经允许,请勿转载。