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


PHP Builder::leftJoin方法代码示例

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


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

示例1: handle

 /**
  * Handle the filter.
  *
  * @param Builder               $query
  * @param SearchFilterInterface $filter
  */
 public function handle(Builder $query, TableBuilder $builder, SearchFilterInterface $filter)
 {
     $stream = $filter->getStream();
     $model = $builder->getTableModel();
     /**
      * If the model is translatable then
      * join it's translations so they
      * are filterable too.
      *
      * @var EloquentQueryBuilder $query
      */
     if ($model->getTranslationModelName() && !$query->hasJoin($model->getTranslationTableName())) {
         $query->leftJoin($model->getTranslationTableName(), $model->getTableName() . '.id', '=', $model->getTranslationTableName() . '.' . $model->getRelationKey());
     }
     $query->where(function (Builder $query) use($filter, $stream) {
         foreach ($filter->getColumns() as $column) {
             $query->orWhere($column, 'LIKE', "%{$filter->getValue()}%");
         }
         foreach ($filter->getFields() as $field) {
             $filter->setField($field);
             $fieldType = $stream->getFieldType($field);
             $fieldTypeQuery = $fieldType->getQuery();
             $fieldTypeQuery->setConstraint('or');
             $this->container->call([$fieldTypeQuery, 'filter'], compact('query', 'filter', 'builder'));
         }
     });
 }
开发者ID:jacksun101,项目名称:streams-platform,代码行数:33,代码来源:SearchFilterQuery.php

示例2: build

 public function build(Builder $query)
 {
     if ($this->person === null) {
         return $query->where(Page::ATTR_ENABLE_ACL, false);
     }
     return $query->leftJoin('page_acl', 'pages.id', '=', 'page_acl.page_id')->leftJoin('group_person', 'page_acl.group_id', '=', 'group_person.group_id')->where(function (Builder $where) {
         $where->where(Page::ATTR_CREATED_BY, $this->person->getId())->orWhereNull('page_acl.group_id')->orWhere('group_person.person_id', $this->person->getId());
     })->groupBy('pages.id');
 }
开发者ID:boomcms,项目名称:boom-core,代码行数:9,代码来源:Acl.php

示例3: newQuery

 /**
  * Overriding newQuery() to the custom PostBuilder with some intereting methods
  * 
  * @param bool $excludeDeleted
  * @return Corcel\PostBuilder
  */
 public function newQuery($excludeDeleted = true)
 {
     $builder = new Builder($this->newBaseQueryBuilder());
     $builder->setModel($this);
     $builder->leftJoin('wp_term_taxonomy', 'wp_terms.term_id', '=', 'wp_term_taxonomy.term_id')->where('wp_term_taxonomy.taxonomy', '=', 'category')->select('wp_terms.*');
     if ($excludeDeleted and $this->softDelete) {
         $builder->whereNull($this->getQualifiedDeletedAtColumn());
     }
     return $builder;
 }
开发者ID:rajivseelam,项目名称:corcel,代码行数:16,代码来源:Category.php

示例4: build

 public function build(Builder $query)
 {
     foreach ($this->tags as $i => $tag) {
         $alias = "pt_without-{$i}";
         $query->leftJoin("pages_tags as {$alias}", function ($q) use($tag, $alias) {
             $q->on('pages.id', '=', "{$alias}.page_id")->on("{$alias}.tag_id", '=', DB::raw($tag->getId()));
         })->whereNull("{$alias}.page_id");
     }
     return $query;
 }
开发者ID:robbytaylor,项目名称:boom-core,代码行数:10,代码来源:WithoutTag.php

示例5: apply

 public function apply(Builder $builder)
 {
     $select = ['Simulation.*', 'Power_Generator.Modality_Id'];
     $builder->with(['Combination.NumericalModel', 'Combination.Protocol', 'Combination.PowerGenerator', 'Combination.PowerGenerator.Modality'])->leftJoin('Power_Generator', 'Power_Generator.Id', '=', 'Combination.Power_Generator_Id')->leftJoin('Combination', 'Combination.Combination_Id', '=', 'Simulation.Combination_Id');
     if (Config::get('gosmart.integrated_patient_database')) {
         $builder->leftJoin('ItemSet as SimulationItem', 'SimulationItem.Id', '=', 'Simulation.Id')->leftJoin('ItemSet as PatientItem', 'PatientItem.Id', '=', 'Simulation.Patient_Id')->leftJoin('ItemSet_Patient', 'ItemSet_Patient.Id', '=', 'Simulation.Patient_Id')->leftJoin('ItemSet_VtkFile as SimulatedLesionSurface', 'SimulatedLesionSurface.Simulation_Id', '=', 'Simulation.Id')->leftJoin('ItemSet_VtuFile as SimulatedLesionVolume', 'SimulatedLesionVolume.Simulation_Id', '=', 'Simulation.Id')->leftJoin('ItemSet_Segmentation', function ($leftJoin) {
             $leftJoin->on('ItemSet_Segmentation.Patient_Id', '=', 'Simulation.Patient_Id');
             $leftJoin->on('ItemSet_Segmentation.State', '=', DB::raw('3'));
             $leftJoin->on('ItemSet_Segmentation.SegmentationType', '=', DB::raw(SegmentationTypeEnum::Lesion));
         })->leftJoin('ItemSet_VtkFile as LesionFile', 'LesionFile.Segmentation_Id', '=', 'ItemSet_Segmentation.Id')->leftJoin('AspNetUsers as Clinician', 'Clinician.Id', '=', 'ItemSet_Patient.AspNetUsersId');
         $select = array_merge($select, ['SimulationItem.CreationDate as creationDate', 'LesionFile.Id as SegmentedLesionId', 'Clinician.Id as ClinicianId', 'Clinician.UserName as ClinicianUserName', 'ItemSet_Patient.Alias as PatientAlias', 'ItemSet_Patient.Description as PatientDescription', 'SimulatedLesionSurface.Id as SimulatedLesionSurfaceId', 'SimulatedLesionVolume.Id as SimulatedLesionVolumeId']);
     }
     $builder->select($select);
 }
开发者ID:philtweir,项目名称:glossia-scratch-test-site,代码行数:14,代码来源:Simulation.php

示例6: filter

 /**
  * Filter a query by the value of a
  * field using this field type.
  *
  * @param Builder         $query
  * @param FilterInterface $filter
  */
 public function filter(Builder $query, FilterInterface $filter)
 {
     $stream = $filter->getStream();
     $assignment = $stream->getAssignment($filter->getField());
     $column = $this->fieldType->getColumnName();
     $translations = $stream->getEntryTranslationsTableName();
     if ($assignment->isTranslatable()) {
         if ($query instanceof EloquentQueryBuilder && !$query->hasJoin($translations)) {
             $query->leftJoin($stream->getEntryTranslationsTableName(), $stream->getEntryTableName() . '.id', '=', $stream->getEntryTranslationsTableName() . '.entry_id');
         }
         $query->addSelect($translations . '.locale');
         $query->addSelect($translations . '.' . $column);
         $query->{$this->where()}(function (Builder $query) use($stream, $filter, $column) {
             $query->where($stream->getEntryTranslationsTableName() . '.locale', config('app.locale'));
             $query->where($stream->getEntryTranslationsTableName() . '.' . $column, 'LIKE', "%" . $filter->getValue() . "%");
         });
     } else {
         $query->{$this->where()}(function (Builder $query) use($stream, $filter, $column) {
             $query->where($stream->getEntryTableName() . '.' . $column, 'LIKE', "%" . $filter->getValue() . "%");
         });
     }
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:29,代码来源:FieldTypeQuery.php

示例7: getRelationCountQuery

 /**
  * Add the constraints for a relationship count query.
  *
  * @param \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder $query
  * @param \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder $parent
  *
  * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder
  */
 public function getRelationCountQuery(Builder $query, Builder $parent)
 {
     $query->select(new Expression('count(*)'));
     $one = $this->getRelated()->getQualifiedKeyName();
     $prev = $this->getForeignKey($this->getRelated());
     $alias = null;
     foreach ($this->models as $model) {
         if ($this->getParent()->getTable() == $model->getTable()) {
             $alias = $model->getTable() . '_' . time();
             $other = $alias . '.' . $prev;
             $query->leftJoin(new Expression($model->getTable() . ' as ' . $alias), $one, '=', $other);
         } else {
             $other = $model->getTable() . '.' . $prev;
             $query->leftJoin($model->getTable(), $one, '=', $other);
         }
         $prev = $this->getForeignKey($model);
         $one = $model->getQualifiedKeyName();
     }
     $key = $this->wrap($this->getQualifiedParentKeyName());
     $query->where(new Expression($alias . '.' . $this->getParent()->getKeyName()), '=', new Expression($key));
     return $query;
 }
开发者ID:blomqvist,项目名称:belongs-to-through,代码行数:30,代码来源:BelongsToThrough.php

示例8: scopeTransactionTypes

 /**
  * @codeCoverageIgnore
  *
  * @param EloquentBuilder $query
  * @param array           $types
  */
 public function scopeTransactionTypes(EloquentBuilder $query, array $types)
 {
     if (is_null($this->joinedTransactionTypes)) {
         $query->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id');
         $this->joinedTransactionTypes = true;
     }
     $query->whereIn('transaction_types.type', $types);
 }
开发者ID:zjean,项目名称:firefly-iii,代码行数:14,代码来源:TransactionJournal.php

示例9: makeJoins

 /**
  * Adds the sql joins to the query.
  *
  * @param \Illuminate\Database\Eloquent\Builder $query
  */
 protected function makeJoins(Builder $query)
 {
     foreach ($this->getJoins() as $table => $keys) {
         $query->leftJoin($table, function ($join) use($keys) {
             $join->on($keys[0], '=', $keys[1]);
             if (array_key_exists(2, $keys) && array_key_exists(3, $keys)) {
                 $join->where($keys[2], '=', $keys[3]);
             }
         });
     }
 }
开发者ID:singgihsap,项目名称:elearning,代码行数:16,代码来源:SearchableTrait.php

示例10: scopeHasMetaValue

 /**
  * @codeCoverageIgnore
  *
  * @param EloquentBuilder $query
  * @param string          $name
  * @param string          $value
  */
 public function scopeHasMetaValue(EloquentBuilder $query, $name, $value)
 {
     $joinName = str_replace('.', '_', $name);
     $query->leftJoin('account_meta as ' . $joinName, function (JoinClause $join) use($joinName, $name) {
         $join->on($joinName . '.account_id', '=', 'accounts.id')->where($joinName . '.name', '=', $name);
     });
     $query->where($joinName . '.data', json_encode($value));
 }
开发者ID:zetaron,项目名称:firefly-iii,代码行数:15,代码来源:Account.php

示例11: join

 /**
  * Apply join query.
  *
  * @param  \Illuminate\Database\Eloquent\Builder  $query
  * @param  string  $foreignTable
  * @param  string  $foreignKey
  * @param  bool $joinToParent
  * @return void
  */
 public function join($query, $foreignTable = null, $foreignKey = null)
 {
     $foreignTable = $foreignTable ?: $query->getModel()->getTable();
     $foreignKey = $foreignKey ?: $this->foreignKey;
     $query->leftJoin($this->tableToJoin(), "{$this->tableAlias}.{$this->primaryKey}", '=', "{$foreignTable}.{$foreignKey}");
 }
开发者ID:sedp-mis,项目名称:base-report,代码行数:15,代码来源:BaseModelGridQuery.php

示例12: makeJoins

 /**
  * Adds the sql joins to the query.
  *
  * @param \Illuminate\Database\Eloquent\Builder $query
  */
 protected function makeJoins(Builder $query)
 {
     foreach ($this->getJoins() as $table => $keys) {
         $query->leftJoin($table, $keys[0], '=', $keys[1]);
     }
 }
开发者ID:xandy3br,项目名称:searchable,代码行数:11,代码来源:SearchableTrait.php

示例13: setRelationQueryConstraints

 /**
  * @param Builder $query
  */
 protected function setRelationQueryConstraints(Builder $query)
 {
     $one = $this->getRelated()->getQualifiedKeyName();
     $prev = $this->getForeignKey($this->getRelated());
     $alias = null;
     $lastIndex = count($this->models);
     foreach ($this->models as $index => $model) {
         if ($lastIndex === $index) {
             $prev = $this->prefix . $prev;
             // TODO: Check if this line is really necessary. Its not covered by any of the tests.
         }
         if ($this->getParent()->getTable() == $model->getTable()) {
             $alias = $model->getTable() . '_' . time();
             $other = $alias . '.' . $prev;
             $query->leftJoin(new Expression($model->getTable() . ' as ' . $alias), $one, '=', $other);
         } else {
             $other = $model->getTable() . '.' . $prev;
             $query->leftJoin($model->getTable(), $one, '=', $other);
         }
         $prev = $this->getForeignKey($model);
         $one = $model->getQualifiedKeyName();
     }
     $key = $this->wrap($this->getQualifiedParentKeyName());
     $query->where(new Expression($alias . '.' . $this->getParent()->getKeyName()), '=', new Expression($key));
 }
开发者ID:znck,项目名称:belongs-to-through,代码行数:28,代码来源:BelongsToThrough.php

示例14: scopeWithReportValue

 /**
  * @param Builder $query
  * @param         $value
  */
 public function scopeWithReportValue(Builder $query, $value)
 {
     // only join if query has no join yet
     $joined = false;
     /** @var JoinClause $join */
     if (!is_null($query->getQuery()->joins)) {
         foreach ($query->getQuery()->joins as $join) {
             if ($join->table == 'reports') {
                 $joined = true;
             }
         }
     }
     if (!$joined) {
         $query->leftJoin('reports', DB::Raw('DATE_FORMAT(log_entries.time,"%y%m%d%H%i")'), '=', DB::Raw('DATE_FORMAT(reports.time, "%y%m%d%H%i")'));
     }
     $joinName = str_replace('.', '_', $value);
     $query->leftJoin('report_values as ' . $joinName, function (JoinClause $join) use($value, $joinName) {
         $join->on('reports.id', '=', $joinName . '.report_id')->where($joinName . '.name', '=', $value);
     });
 }
开发者ID:JC5,项目名称:marauder,代码行数:24,代码来源:LogEntry.php


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