Open juliansteenbakker opened 2 weeks ago
Probably because \Illuminate\Database\Eloquent\Builder::find
transparently supports finding multiple models by their primary key
Actually, it's because generics aren't supported correctly. I tried to fix it on my fork, but it's a bit hard because of the forked phpdoc package that's included.
It should return a TModel, which is defined as template at the top of the Builder class:
Wat worked for me (it's far from ideal though), is replacing the @mixin \Eloquent
for the @mixin Builder<$this>
in each model phpdoc.
This gives the following result:
It can be done using this code snippet (requires the GNU
sed version):
find app/Models -type f -name '*.php' -exec sed -i 's/@mixin Eloquent/@mixin \\Illuminate\\Database\\Eloquent\\Builder<\$this>/g' {} +
find app/Models -type f -name '*.php' -exec sed -i 's/@mixin \\Eloquent/@mixin \\Illuminate\\Database\\Eloquent\\Builder<\$this>/g' {} +
Versions:
Description:
::find returns Illuminate\Database\Eloquent\Collection|null|TModel ::first returns Illuminate\Database\Eloquent\TValue|null