Open Sergiobop opened 1 month ago
Same here.
For example, User::first()
returns a User object. However, after Laravel 11.15, I get an intelephense error if I try to typehint it.
Expected type 'App\Models\User'. Found 'Illuminate\Database\Eloquent\TValue|null'.
From _ide_helper.php:
/**
* Execute the query and get the first result.
*
* @param array|string $columns
* @return \Illuminate\Database\Eloquent\TValue|null
* @static
*/
public static function first($columns = [])
{
/** @var \Illuminate\Database\Eloquent\Builder $instance */
return $instance->first($columns);
}
Hello,
Same for me, all models are viewed as Illuminate\Database\Eloquent\Builder instead of an instance of App\Models\MODELNAME.
Thanks in advance, Max
Same issue here. It seems that Laravel changed the DocBlocks for the Eloquent Builder class in Laravel 11.
It now has a template tag on the class itself @template TModel of \Illuminate\Database\Eloquent\Model
, and it references this template on some of the methods @return TModel
.
Versions:
Description:
Additionally to issues like https://github.com/barryvdh/laravel-ide-helper/issues/1571, Laravel 11.15 also ruined some other _ide_helper.php methods (find, findOrFail, etc)
I think is related to https://github.com/laravel/framework/pull/51851 and https://github.com/laravel/framework/pull/52037
Before 11.15:
After 11.15:
Now for example this is wrong: $pack = Pack::query()->findOrFail($packId);
Previous to 11.15: $pack: Pack|Pack[]|Builder|Builder[]|Collection|Model|null After 11.15: $pack: |Collection|Model|null
I don't know if we have to do something to make it work again in our end.
Thanks