I have a model CheckingAccount
with scopes:
//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 . '%');
}
But PhpStorm fails to recognize them in other classes. For example here in controller:
public function all($filters)
{
return CheckingAccount::query()
->emailLike($filters['email'])
->phoneLike($filters['phone'])
->get();
}
It says method emailLike()
not found and phoneLike()
is not even recognized at all. What is wrong?
Äs LazyOne said
emailLike()
-- it is magic one (during runtime Laravel uses scopeEmailLike()
instead). Try declaring such method using @method
in a PHPDoc for the class.