willslade 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.
JakubMisek Thank you! So $stockItems should be array<Model> instead? May I see how the $stockItems is created?
willslade $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
JakubMisek 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)
willslade Apologies I get what your asking for now. It is a repository wrapper, when you call getModel that returns an Eloquent query instance.
JakubMisek willslade I see! thanks, I'll try to repro the issue; we still have some work to do with eloquent)
JakubMisek OscarJesusSilvaLavalle I would recommend the following workaround instead: /** @var Stage $stage */