public function rebase(DataModel $parentModel) { $this->parentModel = $parentModel; if (count($this->relations)) { foreach ($this->relations as $name => $relation) { /** @var Relation $relation */ $relation->rebase($parentModel); } } }