Esempio n. 1
0
 /**
  * @param \Notadd\Foundation\Database\Eloquent\Builder $query
  * @param \Notadd\Foundation\Database\Eloquent\Builder $parent
  * @return \Notadd\Foundation\Database\Eloquent\Builder
  */
 public function getRelationCountQuery(Builder $query, Builder $parent)
 {
     if ($parent->getQuery()->from == $query->getQuery()->from) {
         return $this->getRelationCountQueryForSelfRelation($query, $parent);
     }
     return parent::getRelationCountQuery($query, $parent);
 }
Esempio n. 2
0
 /**
  * BelongsTo constructor.
  * @param \Notadd\Foundation\Database\Eloquent\Builder $query
  * @param \Notadd\Foundation\Database\Eloquent\Model $parent
  * @param string $foreignKey
  * @param string $otherKey
  * @param string $relation
  */
 public function __construct(Builder $query, Model $parent, $foreignKey, $otherKey, $relation)
 {
     $this->otherKey = $otherKey;
     $this->relation = $relation;
     $this->foreignKey = $foreignKey;
     parent::__construct($query, $parent);
 }
Esempio n. 3
0
 /**
  * HasManyThrough constructor.
  * @param \Notadd\Foundation\Database\Eloquent\Builder $query
  * @param \Notadd\Foundation\Database\Eloquent\Model $farParent
  * @param \Notadd\Foundation\Database\Eloquent\Model $parent
  * @param string $firstKey
  * @param string $secondKey
  * @param string $localKey
  */
 public function __construct(Builder $query, Model $farParent, Model $parent, $firstKey, $secondKey, $localKey)
 {
     $this->localKey = $localKey;
     $this->firstKey = $firstKey;
     $this->secondKey = $secondKey;
     $this->farParent = $farParent;
     parent::__construct($query, $parent);
 }
Esempio n. 4
0
 /**
  * @return string
  */
 public function getMorphClass()
 {
     $morphMap = Relation::morphMap();
     $class = get_class($this);
     if (!empty($morphMap) && in_array($class, $morphMap)) {
         return array_search($class, $morphMap, true);
     }
     return $this->morphClass ?: $class;
 }
Esempio n. 5
0
 /**
  * @param string $relation
  * @return \Notadd\Foundation\Database\Eloquent\Relations\Relation
  */
 protected function getHasRelationQuery($relation)
 {
     return Relation::noConstraints(function () use($relation) {
         return $this->getModel()->{$relation}();
     });
 }