當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。