вла*_*цев 3 php phpdoc phpstorm laravel
我有一个CheckingAccount带有范围的模型:
//scopes
public function scopeEmailLike(Builder $builder, $email)
{
return $this->where($this->table . '.email', 'like', '%' . $email . '%');
}
public function scopePhoneLike(Builder $builder, $phone)
{
return $this->where($this->table . '.phone', 'like', '%' . $phone . '%');
}
Run Code Online (Sandbox Code Playgroud)
但 PhpStorm 无法在其他类中识别它们。例如在控制器中:
public function all($filters)
{
return CheckingAccount::query()
->emailLike($filters['email'])
->phoneLike($filters['phone'])
->get();
}
Run Code Online (Sandbox Code Playgroud)
emailLike()它说找不到方法,甚至phoneLike()根本不被识别。怎么了?
\xc3\x84s LazyOne 说
\nemailLike()——它是神奇的方法(在运行时 Laravel 使用scopeEmailLike())。@method尝试在类的 PHPDoc 中使用声明此类方法。