/** * 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); }
/** * Prefix where clauses' columns. * @param \Sgpatil\Orientdb\Eloquent\Builder $query * @param string $prefix * @return void */ protected function prefixWheres(Builder $query, $prefix) { if (is_array($query->getQuery()->wheres)) { $query->getQuery()->wheres = array_map(function ($where) use($prefix) { $column = $where['column']; $where['column'] = $this->isId($column) ? $column : $prefix . '.' . $column; return $where; }, $query->getQuery()->wheres); } }
/** * Get the current connection name. * * @return string */ public function getConnectionName() { return $this->query->getModel()->getConnectionName(); }