基本上就是這篇文章中描述的內容。在 PHPStorm 中,沒有 Eloquent 方法的代碼提示 - 這很令人困惑(我剛剛學習 Eloquent)。似乎提供的解決方案都不適用于 Laravel 6+。目前使用 Laravel 8。想再次推動這個主題 - 也許有人已經找到了合適的解決方案。代碼示例:應用\模型\Article.php<?phpnamespace App\Models;use Illuminate\Database\Eloquent\Builder;use Illuminate\Database\Eloquent\Factories\HasFactory;use Illuminate\Database\Eloquent\Model;class Article extends Model{ use HasFactory;}控制器:use App\Models\Article;$article = Article::where(...); //no code hint幾乎所有方法都會發生這種情況。
2 回答

DIEA
TA貢獻1820條經驗 獲得超2個贊
您應該使用 laravel-ide-helper 包(https://github.com/barryvdh/laravel-ide-helper)。
安裝:
composer require --dev barryvdh/laravel-ide-helper
模型提示:
php artisan ide-helper:models php artisan ide-helper:models --reset
使用 --reset 選項替換模型中的整個 phpdoc 塊。
門面方法的代碼提示:
php artisan ide-helper:generate
通過容器調用的類的代碼提示:
php artisan ide-helper:meta

達令說
TA貢獻1821條經驗 獲得超6個贊
你必須在使用where語句搜索后使用get來獲取數據,所以你必須在最后使用get。 $articles = Article::where(...)->get();
- 2 回答
- 0 關注
- 219 瀏覽
添加回答
舉報
0/150
提交
取消