Andrew Andrew - 16 days ago 8
PHP Question

PHPStorm auto-complete not working with Laravel 5

I'm using PHP Storm v8.0.3 with the latest version of Laravel.

I'm having trouble making the autocomplete work.

enter image description here

As you can see in the image above.




I have installed barryvdh ide-helper, following the readme he provides on git. I haven't received any errors during its installation.

enter image description here

I have included it in the
providers
array as either

'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider'


or

Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider:class


It didn't make any difference(as far as I can tell).

I have also installed the Laravel plugin.

Again, no difference, still no auto-complete.

enter image description here

I tried dumping the config file which resulted in:

array:27 [▼
...
22 => "Illuminate\View\ViewServiceProvider"
23 => "Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider"
24 => "App\Providers\AppServiceProvider"
...
]


I'm really stuck on this one. I have no idea what could be wrong. Any nudging in the right direction is greatly appreciated.

Answer

Two possible fixes for that:

  1. Make your models extend the \Eloquent facade instead of Illuminate\Database\Eloquent\Model.
  2. If you prefer to keep using the "Model" facade, you can make your own alias in config/app.php, then change "eloquent" to "model" in the config/ide-helper.php under extra. This will let ide-helper include all the methods from Illuminate\Database\Eloquent\Builder and Illuminate\Database\Query\Builder which is where the missing methods actually live.

(Source: https://laracasts.com/discuss/channels/general-discussion/phpstorm-thinks-modelwhere-doesnt-exist-on-model-l5/replies/37661)

Comments