/**
  * Create a new has many relationship instance.
  *
  * @param  \Sgpatil\Orientdb\Eloquent\Builder  $query
  * @param  \Sgpatil\Orientdb\Eloquent\Model  $parent
  * @param  string  $type
  * @return void
  */
 public function __construct(Builder $query, Model $parent, $foreignKey, $localKey)
 {
     $this->localKey = $localKey;
     $this->foreignKey = $foreignKey;
     $this->query = $query;
     $this->parent = $parent;
     $this->related = $query->getModel();
     parent::__construct($query, $parent, $foreignKey->getTable(), $localKey);
 }
 /**
  * Remove the original where clause set by the relationship.
  *
  * The remaining constraints on the query will be reset and returned.
  *
  * @return array
  */
 public function getAndResetWheres()
 {
     // We actually need to remove two where clauses from polymorphic queries so we
     // will make an extra call to remove the first where clause here so that we
     // remove two total where clause from the query leaving only custom ones.
     $this->removeFirstWhereClause();
     return parent::getAndResetWheres();
 }
 /**
  * Create a new has many relationship instance.
  *
  * @param  \Vinelab\NeoEloquent\Eloquent\Builder  $query
  * @param  \Vinelab\NeoEloquent\Eloquent\Model  $parent
  * @param  string  $type
  * @return void
  */
 public function __construct(Builder $query, Model $parent, $type, $key, $relation)
 {
     $this->localKey = $key;
     $this->relation = $relation;
     $this->type = $this->foreignKey = $type;
     parent::__construct($query, $parent, $type, $key);
     $this->finder = $this->newFinder();
 }
Esempio n. 4
0
 /**
  * Create a new has many relationship instance.
  *
  * @param  \Vinelab\NeoEloquent\Eloquent\Builder  $query
  * @param  \Vinelab\NeoEloquent\Eloquent\Model  $parent
  * @param  string  $type
  * @return void
  */
 public function __construct(Builder $query, Model $parent, $type, $key, $relation)
 {
     $this->localKey = $key;
     // mb_strtolower added to make relation ship label in small case
     $this->relation = mb_strtolower($relation);
     $this->type = $this->foreignKey = $type;
     parent::__construct($query, $parent, $type, $key);
     $this->finder = $this->newFinder();
 }
Esempio n. 5
0
 /**
  * Attach a model instance to the parent model.
  *
  * @param  \Illuminate\Database\Eloquent\Model $model
  * @return \Illuminate\Database\Eloquent\Model
  */
 public function save(Model $model)
 {
     $model->setAttribute($this->getPlainMorphType(), $this->morphClass);
     return parent::save($model);
 }
 protected function joinHasRelation(Relations\HasOneOrMany $relation, $type)
 {
     $table = $relation->getRelated()->getTable();
     $foreignKey = $relation->getForeignKey();
     $localKey = $relation->getQualifiedParentKeyName();
     $this->query->join($table, $foreignKey, '=', $localKey, $type);
 }
Esempio n. 7
0
 private function generateNullConditionFromHasOneOrMany(HasOneOrMany $relation)
 {
     $this->query = $this->query->whereNull($relation->getForeignKey());
 }
Esempio n. 8
0
 /**
  * Values constructor.
  *
  * @param Builder        $query
  * @param Eloquent       $parent
  * @param string         $foreignKey
  * @param string         $localKey
  * @param BaseCollection $properties
  */
 public function __construct(Builder $query, Eloquent $parent, $foreignKey, $localKey, BaseCollection $properties = null)
 {
     $this->setProperties($properties);
     parent::__construct($query, $parent, $foreignKey, $localKey);
 }