Laravel和Phpstorm:模型方法未在集合中识别

时间:2015-05-28 07:41:55

标签: php laravel phpstorm

当我做以下事情时:         $ solicitud = Solicitud :: find($ id);         $ extras = $ solicitud-> extras();

PHPstorm无法将$ solicitud识别为Solicitud模型,并在extras()方法中显示警告:“在Illuminate / Support / Collection | static中找不到方法附加内容”

如果我使用@var注释,警告会消失,但是有一种自动修复方法吗?

1 个答案:

答案 0 :(得分:0)

我以前使用Laravel 4遇到过这个问题,当时模型只是扩展\Eloquent,虽然编程上很好,但PHPStorm并不知道\Eloquent是什么在laravel运行其bootstraping以在配置文件中注册别名后进行设置。

在你的模特中你只需要扩展Illuminate\Database\Eloquent\Model

use Illuminate\Database\Eloquent\Model as Eloquent;

class Solicitud extends Eloquent {
    // Usual model code
}