PHPStorm 无法识别 Laravel 5.0 中我的模型类的方法
问题描述
向数据库中插入数据失败,IDE (phpStrom) 中未找到所有查询类和模型类的方法,我该如何解决?
failed insert data into database, and all query class and Model class's method not found show in IDE (phpStrom) how can I solve it?
这是我的扩展类(Post.php),这里显示最新的错误和方法:
here is my extended class (Post.php) here show error in latest and where method:
这是我使用它的控制器类:
and Here is my Controller class where i use it :
推荐答案
如果你想要一个扩展 Model
的类来识别 Eloquent 方法,只需在该类的 PHPDoc 顶部注释中添加以下内容:
If you want a class extending Model
to recognize Eloquent methods, just add the following in the top PHPDoc comment on the class:
示例:
编辑 Laravel 6+
注意:你们中的大多数人可能正在为 Laravel 使用 ide-helper,因此这个 @mixin
属性为模型类自动生成.
Note:
Most of you probably are using ide-helper for Laravel, therefore this @mixin
attribute is automatically generated for model Classes.
这篇关于PHPStorm 无法识别 Laravel 5.0 中我的模型类的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!