3

(I have checked previous posts regarding this situation)

On the pictures below you see code from the SAME file "StripeController.php"

Both Classes/Models (StripeEvent and Transaction) extends Model, has

namespace App\Models, and uses:

use Illuminate\Database\Eloquent\Factories\HasFactory;

use Illuminate\Database\Eloquent\Model;

This line is NOT present in any of those Models (use Illuminate\Database\Eloquent\Builder)

No DOC blocs are present in both Classes/Models.

Here PhpStorm says that "firstWhere" method not found on StripeEvent model: enter image description here

But on previous line (in the same file) with Transaction model PhpStorm finds this method: enter image description here

I tried to create other new models, but problem remains the same. Methods are recognized by PhpStorm only for old/previously created models, but NOT recognized for new ones.

I suspect that there might be some config or helper cache that should be re-generated.

Any ideas how to fix it and make PhpStorm code hint and not underline eloquent methods?

1 Answer 1

8

If you are using Laravel Idea in your PhpStorm, you need to click "Laravel / Generate Helper Code" in the top menu. Also, if you have Laravel IDE Helper package in your laravel app, you can use the following commands:

php artisan ide-helper:generate
php artisan ide-helper:models
php artisan ide-helper:meta
Sign up to request clarification or add additional context in comments.

2 Comments

Yea, I use Laravel Idea and "Generate Helper Code" solved the situation. You also mentioned Laravel IDE Helper. Can it be used together with Laravel Idea, i mean will there be no conflicts? Thank you for advice.
You're welcome. I didn't use both simultaneously, so I cannot say for sure. My guess is it doesn't lead to a significant problem. Maybe you would get a "Multiple definitions exist for class" notice in the code analysis of PhpStorm (If you get the notice, you can look at here).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.