Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 protected function initNestedQuery(QueryBuilder $query, array $ids)
 {
     parent::initNestedQuery($query, $ids);
     $query->where($this->relation->getMorphType(), '=', $this->relation->getMorphClass());
 }
Esempio n. 2
0
 public function __construct(Builder $query, Model $parent, $name, $table, $foreignKey, $otherKey, $relationName = null, $inverse = false, $relation_id = null)
 {
     $this->relation_id = $relation_id;
     parent::__construct($query, $parent, $name, $table, $foreignKey, $otherKey, $relationName, $inverse);
 }
 /**
  * Create a new morph to many relationship instance.
  *
  * @param Builder $query
  * @param Model   $parent
  * @param string  $name
  * @param string  $table
  * @param string  $foreignKey
  * @param string  $otherKey
  * @param string  $orderColumn
  * @param string  $relationName
  * @param bool    $inverse
  */
 public function __construct(Builder $query, Model $parent, $name, $table, $foreignKey, $otherKey, $orderColumn, $relationName = null, $inverse = false)
 {
     parent::__construct($query, $parent, $name, $table, $foreignKey, $otherKey, $relationName, $inverse);
     $this->setOrderColumn($orderColumn);
 }
Esempio n. 4
0
 /**
  * Modify an eager load query to only load media assigned to all provided tags simultaneously.
  * @param  \Illuminate\Database\Eloquent\Relations\MorphToMany $q
  * @param  array|string                                        $tags
  * @return void
  */
 protected function addMatchAllToEagerLoadQuery(MorphToMany $q, $tags = [])
 {
     $tags = (array) $tags;
     $grammar = $q->getConnection()->getQueryGrammar();
     $subquery = $this->newMatchAllQuery($tags)->select($q->getOtherKey());
     $q->wherePivotIn('tag', $tags)->whereRaw($grammar->wrap($q->getOtherKey()) . ' IN (' . $subquery->toSql() . ')', $subquery->getBindings());
 }