/** * Pivot constructor. * @param \Notadd\Foundation\Database\Eloquent\Model $parent * @param string $attributes * @param string $table * @param bool $exists */ public function __construct(Model $parent, $attributes, $table, $exists = false) { parent::__construct(); $this->setTable($table); $this->setConnection($parent->getConnectionName()); $this->forceFill($attributes); $this->syncOriginal(); $this->parent = $parent; $this->exists = $exists; $this->timestamps = $this->hasTimestampAttributes(); }
/** * @param array $columns * @return \Notadd\Foundation\Database\Eloquent\Model[] */ public function getModels($columns = ['*']) { $results = $this->query->get($columns); $connection = $this->model->getConnectionName(); return $this->model->hydrate($results, $connection)->all(); }