parental icon indicating copy to clipboard operation
parental copied to clipboard

feat: add `toChildModel` method

Open jaulz opened this issue 1 year ago • 2 comments

It would be great if there was a toChildModel method that I can easily use to convert parent models to child models. Please let me know if you like the idea so I can create corresponding tests.

jaulz avatar Dec 17 '24 11:12 jaulz

So this would be used if the class you're instantiating is the parent class, right? Something like:

$obj = new User(['type' => 'admin', ....]); // Instance of User class
$obj->toChildModel(); // Creates an instance of the Admin class, passing along the attributes

I think I like that.

tonysm avatar Apr 15 '25 16:04 tonysm

Yep, exactly. I can add tests if you are okay with it 😊

jaulz avatar Apr 15 '25 20:04 jaulz