tighten / parental

Use single table inheritance in your Laravel app
MIT License
1.36k stars 98 forks source link

Allow a model to be both a parent and child #104

Open chadhutchins opened 2 years ago

chadhutchins commented 2 years ago

The only reason this didn't work previously was due to duplicate method names in HasParent and HasChildren traits.

We have a use case where we have several layers of abstraction:

A extends B B extends C

With this change we can now:

A HasParent B HasParent, Has Children C Has Children

and by C::find('1234') will return the class instance of A correctly.

tobias-grasse commented 1 year ago

@driftingly Is there something to be done before this can be merged? I'd be interested in this functionality, so I'd be glad to help.

driftingly commented 1 year ago

@tobias-grasse If you're able to, tests would be helpful.

driftingly commented 1 year ago

I ran this update through the test suite of a larger project and didn't run into any issues.