Jan 13, 2025
0
Level 7
Larastan/phpstan fail on with eloquent model
code:
- files is a morph to many relation in category model
- search is a scope on the file model
$categoryQuery->with('files', function (MorphToMany $q) use ($request) {
$q->search(request('q'));
});
phpstan:
27 Parameter #2 $callback of method Illuminate\Database\Eloquent\Builder<App\Models\Category>::with() expects
(Closure(Illuminate\Database\Eloquent\Relations\Relation<*, *, *>): mixed)|string|null,
Closure(Illuminate\Database\Eloquent\Relations\MorphToMany): void given.
🪪 argument.type
28 Call to an undefined method Illuminate\Database\Eloquent\Relations\MorphToMany::search().
🪪 method.notFound
Please or to participate in this conversation.