Example #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);
 }
Example #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);
 }
 /**
  * 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);
 }
Example #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;
 }
Example #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}();
     });
 }