/** * @param \Notadd\Foundation\Database\Eloquent\Builder $query * @param \Notadd\Foundation\Database\Eloquent\Builder $parent * @return \Notadd\Foundation\Database\Eloquent\Builder */ public function getRelationCountQueryForSelfRelation(Builder $query, Builder $parent) { $query->select(new Expression('count(*)')); $query->from($query->getModel()->getTable() . ' as ' . ($hash = $this->getRelationCountHash())); $key = $this->wrap($this->getQualifiedParentKeyName()); return $query->where($hash . '.' . $this->getPlainForeignKey(), '=', new Expression($key)); }
/** * @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) { $query->select(new Expression('count(*)')); $key = $this->wrap($this->getQualifiedParentKeyName()); return $query->where($this->getHasCompareKey(), '=', new Expression($key)); }
/** * @param \Notadd\Foundation\Database\Eloquent\Builder $query * @return \Notadd\Foundation\Database\Eloquent\Builder */ protected function setKeysForSaveQuery(Builder $query) { $query->where($this->getKeyName(), '=', $this->getKeyForSaveQuery()); return $query; }
/** * @param \Notadd\Foundation\Database\Eloquent\Builder $query * @return \Notadd\Foundation\Database\Eloquent\Builder */ protected function setKeysForSaveQuery(Builder $query) { $query->where($this->foreignKey, $this->getAttribute($this->foreignKey)); return $query->where($this->otherKey, $this->getAttribute($this->otherKey)); }
/** * @param \Notadd\Foundation\Database\Eloquent\Builder $query * @return \Notadd\Foundation\Database\Eloquent\Builder */ protected function setKeysForSaveQuery(Builder $query) { $query->where($this->morphType, $this->morphClass); return parent::setKeysForSaveQuery($query); }