laravel-ide-helper 的问题

Problems with laravel-ide-helper

我正在学习 Laravel 5 Laracasts video 基础知识,但在我的 IDE (Phpstorm 8) 中遇到了一些 Facades 问题。我有一个使用 Eloquent 门面 use Illuminate\Database\Eloquent\Model;

的模型

我需要 laravel-ide-helper composer require barryvdh/laravel-ide-helper,将服务 provider 添加到 providers 数组 'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider',,重新生成文档并重新启动我的 IDE,但没有成功。

我的控制器中有一个模型 decleration $article = Article::findOrFail($id); 但是 findOrFail 方法被突出显示并标记为方法 'findOrFail' 在 class App\Article 中找不到.

我不熟悉 Laravel 和 Facades 的概念,但我迷路了,无法找到解决我的问题的现有答案。

你试过了吗php artisan ide-helper:generate

如果在生成过程中遇到问题,也可以直接复制预生成的要点:

curl -O "https://gist.githubusercontent.com/barryvdh/5227822/raw/811f21a14875887635bb3733aef32da51fa0501e/_ide_helper.php"

来源:https://github.com/barryvdh/laravel-ide-helper

https://github.com/barryvdh/laravel-ide-helper/issues/248#issuecomment-131503475

As far as findOrFail goes I've had luck using class CLASSNAME extends \Eloquent instead of class CLASSNAME extends Model within your Model. This workaround will cause it to use the helper file, so I believe you will need to deploy WITH the ide-helper file, but I'm not certain.

That will get most of them working it seems, however I'm still having issues getting where to work within my Model, not sure if it has to do with how I'm calling it $query->where(..., but using \Eloquent seems to fix most of the methods.