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


PHP Relation::getQuery方法代码示例

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


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

示例1: deleteAllRelatedExcept

 /**
  * @param Relation $relation
  * @param array    $excluded_ids
  */
 public static function deleteAllRelatedExcept(Relation $relation, $excluded_ids = [])
 {
     $related = $relation->getRelated();
     $key_name = $related->getKeyName();
     $query = $relation->getQuery();
     if (count($excluded_ids) > 0) {
         $query->whereNotIn($key_name, $excluded_ids);
     }
     $query->delete();
 }
开发者ID:exolnet,项目名称:laravel-module,代码行数:14,代码来源:Helper.php

示例2: getRelationshipWheres

 /**
  * Sets up the existing relationship wheres.
  *
  * @param \Illuminate\Database\Eloquent\Relations\Relation $relationship
  * @param string                                           $tableAlias
  * @param string                                           $pivotAlias
  * @param string                                           $pivot
  *
  * @return string
  */
 public function getRelationshipWheres($relationship, $tableAlias, $pivotAlias = null, $pivot = null)
 {
     //get the relationship model
     $relationshipModel = $relationship->getRelated();
     //get the query instance
     $query = $relationship->getQuery()->getQuery();
     //get the connection instance
     $connection = $query->getConnection();
     //one element of the relationship query's wheres is always useless (it will say pivot_table.other_id is null)
     //depending on whether or not softdeletes are enabled on the other model, this will be in either position 0
     //or 1 of the wheres array
     array_splice($query->wheres, method_exists($relationshipModel, 'getDeletedAtColumn') ? 1 : 0, 1);
     //iterate over the wheres to properly alias the columns
     foreach ($query->wheres as &$where) {
         //alias the where columns
         $where['column'] = $this->aliasRelationshipWhere($where['column'], $tableAlias, $pivotAlias, $pivot);
     }
     $sql = $query->toSql();
     $fullQuery = $this->interpolateQuery($sql, $connection->prepareBindings($query->getBindings()));
     $split = explode(' where ', $fullQuery);
     return isset($split[1]) ? $split[1] : '';
 }
开发者ID:hifone,项目名称:dashboard,代码行数:32,代码来源:Relationship.php

示例3: addHasWhere

 /**
  * Add the "has" condition where clause to the query.
  *
  * @param  \Illuminate\Database\Eloquent\Builder  $hasQuery
  * @param  \Illuminate\Database\Eloquent\Relations\Relation  $relation
  * @param  string  $operator
  * @param  int  $count
  * @param  string  $boolean
  * @return \Illuminate\Database\Eloquent\Builder|static
  */
 protected function addHasWhere(Builder $hasQuery, Relation $relation, $operator, $count, $boolean)
 {
     $hasQuery->mergeModelDefinedRelationConstraints($relation->getQuery());
     if ($this->shouldRunExistsQuery($operator, $count)) {
         $not = $operator === '<' && $count === 1;
         return $this->addWhereExistsQuery($hasQuery->toBase(), $boolean, $not);
     }
     return $this->whereCountQuery($hasQuery->toBase(), $operator, $count, $boolean);
 }
开发者ID:levanigongadze,项目名称:Labweb,代码行数:19,代码来源:Builder.php


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