Inconsistent behaviour in relation manager dependency injection
Hi, why is it that if I use dependency injection in a relationship manager table row, sometimes the model is loaded with the related relationship records and sometimes not?
For example, in a scenario where
Foo
has a one-to-many relationship with Bar
via the bars()
relationship.
Inside the BarsRelationManager
of the FooResource
I have the following code:
The output is something like this:
How come that $ownerFromLivewire
which uses the $livewire
property to get the owner record successfully retrieves the relation records, while $owner
which explicitly loads the relationship and $ownerRecord
which does not both do not retrieve the relation records?
I tested it with and without Model::preventLazyLoading()
and both return the same results.
Am I missing something?4 Replies
Is
$owner
even the correct model? Same ID? Or did it just inject an empty model?Ah, lol yeah. I shouldn't program that late in the night π
Thanks π
in v4 models incorrectly injected will throw an exception
Very nice, this has bitten me than once already π
Although it would be nice if the
Although it would be nice if the
owner
record could also be injected where applicable instead of having to go through the livewire component.