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


PHP Builder::join方法代码示例

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


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

示例1: handle

 /**
  * Handle the command.
  *
  * @param RoleRepositoryInterface $roles
  */
 public function handle(RoleRepositoryInterface $roles)
 {
     if (!$this->query->getQuery()->joins && ($permission = array_get($this->fieldType->getConfig(), 'permission'))) {
         $accessible = $roles->findByPermission($permission);
         if (!$accessible->isEmpty()) {
             $this->query->join('users_users_roles', 'users_users_roles.entry_id', '=', 'users_users.id')->whereIn('users_users_roles.related_id', $accessible->lists('id'));
         }
     }
 }
开发者ID:visualturk,项目名称:user-field_type,代码行数:14,代码来源:QueryWithPermission.php

示例2: 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)
 {
     if (isset($model->required) && $model->required) {
         $builder->join('tmp_documents', function ($join) {
             $join->on('tmp_documents.id', '=', 'persons_documents.document_id')->where('is_required', '=', true)->wherenull('persons_documents.deleted_at');
         });
     } else {
         $builder->join('tmp_documents', function ($join) {
             $join->on('tmp_documents.id', '=', 'persons_documents.document_id')->where('is_required', '=', false)->wherenull('persons_documents.deleted_at');
         });
     }
 }
开发者ID:ThunderID,项目名称:HRIS-API,代码行数:19,代码来源:DocumentRequiredScope.php

示例3: apply

 /**
  * Apply the scope to a given Eloquent query builder.
  * @param Builder $builder
  * @param Model $model
  */
 public function apply(Builder $builder, Model $model)
 {
     $builder->join('product_translations', function ($join) {
         $join->on('products.id', '=', 'product_translations.product_id')->where('product_translations.locale', '=', app()->getLocale())->where('product_translations.published', '=', 1);
     });
     $builder->select(['products.*']);
 }
开发者ID:jaffle-be,项目名称:framework,代码行数:12,代码来源:ProductScopeFront.php

示例4: build

 public function build(Builder $query)
 {
     $tagIds = array_map(function (TagInterface $tag) {
         return $tag->getId();
     }, $this->tags);
     return $query->join('pages_tags', 'pages.id', '=', 'pages_tags.page_id')->whereIn('pages_tags.tag_id', $tagIds)->groupBy('pages.id')->having(DB::raw('count(distinct pages_tags.tag_id)'), '=', count($tagIds));
 }
开发者ID:boomcms,项目名称:boom-core,代码行数:7,代码来源:AllTags.php

示例5: build

 public function build(Builder $query)
 {
     $page = $this->page;
     return $query->join('pages_tags', 'tags.id', '=', 'pages_tags.tag_id')->join('pages', 'pages_tags.page_id', '=', 'pages.id')->where(function ($query) use($page) {
         $query->where('pages.id', '=', $page->getId())->orWhere('pages.parent_id', '=', $page->getId());
     })->groupBy('tags.id')->orderBy('tags.name', 'asc');
 }
开发者ID:robbytaylor,项目名称:boom-core,代码行数:7,代码来源:AppliedToPageDescendants.php

示例6: onQuerying

 /**
  * Fired just before querying
  * for table entries.
  *
  * @param Builder $query
  */
 public function onQuerying(Builder $query)
 {
     $uploaded = $this->getUploaded();
     if ($fieldType = $this->getFieldType()) {
         /*
          * If we have the entry available then
          * we can determine saved sort order.
          */
         $entry = $fieldType->getEntry();
         $table = $fieldType->getPivotTableName();
         if ($entry->getId() && !$uploaded) {
             $query->join($table, $table . '.file_id', '=', 'files_files.id');
             $query->where($table . '.entry_id', $entry->getId());
             $query->orderBy($table . '.sort_order', 'ASC');
         } else {
             $query->whereIn('id', $uploaded ?: [0]);
         }
     } else {
         /*
          * If all we have is ID then just use that.
          * The JS / UI will be handling the sort
          * order at this time.
          */
         $query->whereIn('id', $uploaded ?: [0]);
     }
 }
开发者ID:anomalylabs,项目名称:files-field_type,代码行数:32,代码来源:ValueTableBuilder.php

示例7: scopeSiblings

 /**
  * Get the siblings of the specified entry ID
  *
  * @param  \Illuminate\Database\Eloquent\Builder $query
  * @param  int|array                             $entryId
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function scopeSiblings(Builder $query, $entryId)
 {
     $entryId = is_array($entryId) ? $entryId : array($entryId);
     $connection = $query->getQuery()->getConnection();
     $tablePrefix = $connection->getTablePrefix();
     return $query->join('relationships', 'relationships.child_id', '=', 'channel_titles.entry_id')->join($connection->raw("`{$tablePrefix}relationships` AS `{$tablePrefix}relationships_2`"), 'relationships_2.parent_id', '=', 'relationships.parent_id')->addSelect('*')->addSelect('relationships_2.child_id AS sibling_id')->whereIn('relationships_2.child_id', $entryId)->orderBy('relationships.order', 'asc')->groupBy('relationships_2.child_id')->groupBy('relationships.field_id')->groupBy('channel_titles.entry_id');
 }
开发者ID:khaliqgant,项目名称:Deep,代码行数:14,代码来源:RelationshipEntry.php

示例8: apply

 /**
  * @param Builder $builder
  * @param Model $model
  */
 public function apply(Builder $builder, Model $model)
 {
     $builder->join('post_translations', function ($join) {
         $join->on('posts.id', '=', 'post_translations.post_id')->where('post_translations.locale', '=', app()->getLocale())->where('post_translations.publish_at', '<', Carbon::now()->format('Y-m-d H:i:s'));
     });
     $builder->select(['posts.*']);
 }
开发者ID:jaffle-be,项目名称:framework,代码行数:11,代码来源:PostScopeFront.php

示例9: apply

 /**
  * Apply the scope to a given Eloquent query builder.
  * @param Builder $builder
  * @param Model $model
  */
 public function apply(Builder $builder, Model $model)
 {
     $builder->join('uris', function ($join) use($model) {
         $join->where('uris.owner_type', '=', get_class($model));
         $join->on('uris.owner_id', '=', $model->getTable() . '.' . $model->getKeyName());
     })->select([$model->getTable() . '.*', 'uris.uri']);
 }
开发者ID:jaffle-be,项目名称:framework,代码行数:12,代码来源:SiteSluggableScope.php

示例10: 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->join($model->getVersionTable(), function ($join) use($model) {
         $join->on($model->getQualifiedKeyName(), '=', $model->getQualifiedVersionKeyName());
         $join->on($model->getQualifiedVersionColumn(), '=', $model->getQualifiedLatestVersionColumn());
     });
     $this->extend($builder);
 }
开发者ID:Tapioca,项目名称:eloquent-versioning,代码行数:15,代码来源:VersioningScope.php

示例11: build

 public function build(Builder $query)
 {
     foreach ($this->tags as $i => $tag) {
         $alias = "tag-{$i}";
         $query->join("pages_tags as {$alias}", 'pages.id', '=', "{$alias}.page_id")->where("{$alias}.tag_id", '=', $tag->getId());
     }
     return $query;
 }
开发者ID:robbytaylor,项目名称:boom-core,代码行数:8,代码来源:Tag.php

示例12: handle

 /**
  * Handle the command.
  *
  * @param RoleRepositoryInterface $roles
  */
 public function handle(RoleRepositoryInterface $roles)
 {
     if ($role = array_get($this->fieldType->getConfig(), 'role')) {
         if (is_numeric($role)) {
             $role = $roles->find($role);
         }
         if (is_string($role)) {
             $role = $roles->findBySlug($role);
         }
         if ($role) {
             // The role exists so join and limit results to that role's ID.
             $this->query->join('users_users_roles', 'users_users_roles.entry_id', '=', 'users_users.id')->where('users_users_roles.related_id', $role->getId());
         } else {
             // The role doesn't exist so don't return anything.
             $this->query->join('users_users_roles', 'users_users_roles.entry_id', '=', 'users_users.id')->where('users_users_roles.related_id', false);
         }
     }
 }
开发者ID:visualturk,项目名称:user-field_type,代码行数:23,代码来源:QueryWithRole.php

示例13: generateJoin

 /**
  * @param string $table
  * @param array $ons
  * @param array $conditions
  * @param string $joinType
  *
  * @throws \InvalidArgumentException
  */
 private function generateJoin($table, $ons, $conditions = array(), $joinType = '')
 {
     $this->query->join($table, function (JoinClause $q) use($conditions, $ons) {
         foreach ($ons as $on) {
             $q->on($on[0], array_key_exists(2, $on) ? $on[2] : '=', $on[1]);
         }
         $this->generateJoinConstraints($q, $conditions);
     }, null, null, $joinType === '' ? $this->joinType : $joinType);
 }
开发者ID:brazenvoid,项目名称:better-eloquent,代码行数:17,代码来源:JoinBuilder.php

示例14: build

 public function build(Builder $query)
 {
     $query->join('assets_tags', 'assets_tags.asset_id', '=', 'assets.id');
     if (is_array($this->tags)) {
         $query->whereIn('assets_tags.tag', $this->tags)->groupBy('tag')->having(DB::raw('count(distinct tag)'), '=', count($this->tags));
     } else {
         $query->where('assets_tags.tag', '=', $this->tags);
     }
     return $query;
 }
开发者ID:robbytaylor,项目名称:boom-core,代码行数:10,代码来源:Tag.php

示例15: modifyQuery

 public function modifyQuery(Builder $query)
 {
     $query->join('users', 'users.id', '=', 'team_users.user_id');
     if ($this->get('team_id')) {
         $query->where('team_id', $this->get('team_id'));
     }
     if ($this->get('user_id')) {
         $query->where('user_id', $this->get('user_id'));
     }
     return $query;
 }
开发者ID:ohiocms,项目名称:core,代码行数:11,代码来源:PaginateRequest.php


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