laravel-idea / plugin

Laravel Idea plugin for PhpStorm
https://laravel-idea.com/
177 stars 7 forks source link

[Bug]: Model first() method return Model instead of Model|null #1093

Open DesolatorMagno opened 3 weeks ago

DesolatorMagno commented 3 weeks ago

Bug description

Don't know exactly where to report this but i think it maybe a problem with the helper code generate.

When i need to do a request for a register in database if i use the first() method with a model, be it directly or adding where clauses first, the var who is holding the response would indicate that the value is the model, but it should be Model|null (i notice it because php hammer give a warning about is_null being unnecessary here), a simple example would be:

$user = User::first();
//or $user = User::where('status', 1)->first();

Now, funny enough, if i add query() before the first() then it works as intended, the var appears as User|null.

$user = User::query()->first();

Plugin version

8.4.0.242

Operating system

Windows

Steps to reproduce

Use the first method with any model $user = User::first();

Relevant log output

No response