Reputation: 31
I'm working on a project using Laravel 5.5 and I'm using PhpStorm as IDE but it shows me
"Method 'table' not found in \Illuminate\Support\Facades\DB..."
"Referenced method is not found in subject class.. "
The code however is working perfectly but still want to know the perfect syntax.
Upvotes: 2
Views: 7498
Reputation: 131
To enable helpers for ide it is important to add "User::query()" if we user query() method then ide will not give such warnings it is best way to easily find eloquent feature.
Without ::query() we can't analyse that followed functions like "where, with, all, get" recognized or not.
Upvotes: 0
Reputation: 99
even if you install the barryvdh/laravel-ide-helper the problem persist, there's a quick solution for this problem, if you look in the /vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php class and Add this PhpDoc
/**
* @mixin \Eloquent
* @mixin \Illuminate\Database\Eloquent\Builder
*/
PhpStorm will now recognize all the Query building methods for all your models
Upvotes: 9
Reputation: 46
Your issue is already mentionned here : https://github.com/laravel/framework/issues/9162
It is an issue after 5.0.33 update.
Try directly this in your code:
\DB::table('...')->get();
Upvotes: 0
Reputation: 448
Install https://github.com/barryvdh/laravel-ide-helper
composer require barryvdh/laravel-ide-helper
register it in config/app.php
use it to generate facades doc
php artisan ide-helper:generate
Upvotes: 4