4

I am going through the Laravel 5 Fundamentals Laracasts video set but am having some difficulties with Facades in my IDE (Phpstorm 8). I have a model which uses the Eloquent facade use Illuminate\Database\Eloquent\Model;

I have required the laravel-ide-helper composer require barryvdh/laravel-ide-helper, added the service provider to the providers array 'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider',, regenerated the docs and restarted my IDE, but with no success.

I have a Model decleration in my Controller $article = Article::findOrFail($id); but the findOrFail method is highlighted and flagged as Method 'findOrFail' not found in class App\Article.

I am new to Laravel and the concept of Facades but am lost and have been unable to find an existing answer for my problem.

Kevbot
  • 474
  • 8
  • 21

2 Answers2

5

Have you tried php artisan ide-helper:generate?

If you have problems during generation, you could also just copy the pre-generated gist:

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

Source: https://github.com/barryvdh/laravel-ide-helper

Kevin Lee
  • 1,171
  • 12
  • 30
0

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.

Community
  • 1
  • 1
  • 1
    Please try to explain it in your own words to, taking the specific problem the OP has and providing a step by step solution – davejal Nov 22 '15 at 03:23