Search code examples
phplaraveleloquentphpstorm

PhpStorm (Laravel 8) all standart eloquent methods not found on one model, but available on another (no code hinting)


(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?


Solution

  • 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