laravel-graphql
laravel-graphql copied to clipboard
Problem with custom query (where - like)
I added custom query field 'nameLike' in my UsersQuery file. But its don't work with multiple query filter. It's only work when i use alone. Please help.
in args function
'nameLike' => ['name' => 'nameLike', 'type' => Type::string()]
in resolve function
else if (isset($args['nameLike'])) {
return $user->where(function ($query) use ($args) {
$query->where('name', 'like', '%' . $args['nameLike'] . '%');
})->get();
}
But its don't work with multiple query filter
What do you mean by that?
Do you mean multiple e.g. space separated words in $args['nameLike']
should word as independent OR
conditions? Then you've to manually split the string up and use ->orWhere
, etc.
You can use this package to creating an advanced search and custom filters.
https://github.com/mohammad-fouladgar/eloquent-builder