From 2ed663df15a8a7728d2e6c2af9ef5d016e6b319b Mon Sep 17 00:00:00 2001 From: Julian Hundeloh <5358638+jaulz@users.noreply.github.com> Date: Tue, 17 Dec 2024 12:44:06 +0100 Subject: [PATCH] feat: add `toChildModel` method --- src/HasChildren.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/HasChildren.php b/src/HasChildren.php index aa5c31e..4fb1726 100644 --- a/src/HasChildren.php +++ b/src/HasChildren.php @@ -245,6 +245,16 @@ public function getChildTypes(): array return []; } + /** + * Create a child model from the current instance. + * + * @return static + */ + public function toChildModel(): self + { + return $this->newInstance($this->getAttributes(), $this->exists); + } + /** * @return mixed */