/** * @param Relation $relation */ protected function preserveKeys(Relation $relation) { if ($relation instanceof HasOneOrMany) { $fk = str_replace($this->getTable() . '.', '', $relation->getForeignKey()); $this->attributes[$fk] = $relation->getParentKey(); } }