Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
DesolatorMagno opened this issue Nov 1, 2024 · 0 comments
Open

Comments

@DesolatorMagno
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant