Why isn't my IDE auto-completing the findOrFail method?

kal*_*dan 3 laravel lumen

So I've created a Message model:

namespace App\Model;

use Illuminate\Database\Eloquent\Model;

class Message extends Model
{
    public function getName()
    {
        return $this->name;
    }

    public function setSortOrder($sortOrder)
    {
        $this->sort_order = $sortOrder;
        return $this;
    }
}
Run Code Online (Sandbox Code Playgroud)

And it seems to be working just fine - I've created some columns using migrations, loaded, and saved the model.

But my IDE (PHP Storm) doesn't seem to be recognizing some of the methods on the model - namely findOrFail. It does autocomplete findOrNew though.

Wondering whether something in lumen is pointing to a more stripped-down version of the base model class. But again the weird thing is that this method is working just fine when I run it - it's just the IDE that doesn't seem to be aware of it.

在此输入图像描述

Update

感谢@ joseph-silber关于PHPStorm的Laravel插件的提示.我刚刚发现并安装了它.我没有立即看到任何可以在那里启用docblock生成的设置.

在此输入图像描述

在Laravel插件页面的注释中,它提到了"Laravel IDE Helper Generator".我做了搜索,发现了我安装的Haehnchen的Laravel插件.

这ide-helper:models为我的工匠命令列表以及其他一些选项添加了选项.我运行它,它确实在docblock中生成了一些方法但不是全部.

在此输入图像描述

Jos*_*ber 7

因为模型类没有findOrFail方法.

它仅在构建器上可用,它从模型的catch-all __call方法调用.


如果您希望PHP Storm帮助您,请尝试使用Laravel插件生成IDE类.