I'm using MannikJ/laravel-sti
but the following code has a different behaviour in tinker and in a controller (assuming the definitions in larevel-sti
's documentation, with classes Root
, Sub1
and Sub2
):
Root::find(1234)
In tinker, it correctly returns an instance of Sub1
. But in a controller, it returns null
.
I get the correct instance in the controller if I replace the code with:
Sub1::find(1234)
Thanks to the maintainer (cf. issue #1), we found that the problem is that we use constructors in our objects but laravel-sti
's trait also does. Constructors are a known issue in PHP with traits…