When it checks for errors its checking the wrong class, this is an \Illuminate\Database\Eloquent\Model object but it misassumes it as \Illuminate\Database\Eloquent\Builder which then returns the error.
When it checks for errors its checking the wrong class, this is an \Illuminate\Database\Eloquent\Model object but it misassumes it as \Illuminate\Database\Eloquent\Builder which then returns the error.
Thank you!
So $stockItems
should be array<Model>
instead?
May I see how the $stockItems
is created?
$stockItems should be an items collection, which is essentially an object. https://github.com/laravel/framework/blob/9.x/src/Illuminate/Database/Eloquent/Collection.php
$stockItem should be an Eloquent Model https://github.com/laravel/framework/blob/9.x/src/Illuminate/Database/Eloquent/Model.php
willslade right, I'm just trying to find out, where was the $stockItems
variable created, or how did it get the type wrong. I don't see any docblock on the screenshot)
Apologies I get what your asking for now. It is a repository wrapper, when you call getModel that returns an Eloquent query instance.
willslade I see! thanks, I'll try to repro the issue; we still have some work to do with eloquent)
Same problem here
I solved the "issue" with this!
$stage = (object) $stage;
OscarJesusSilvaLavalle I would recommend the following workaround instead:
/** @var Stage $stage */