Replies: 1 comment
-
After scratching my head, I got it! ...
use Spatie\Searchable\Search as SpatieSearch;
use Illuminate\Support\Traits\Conditionable;
class Search extends SpatieSearch
{
use Conditionable;
}
...
$result = (new Search())
->when(Str::length($query) >= 3, function($search) use ($query) {
return $search->registerModel(Trip::class, ['title', 'place'])
->registerModel(Series::class, 'title')
->registerModel(User::class, ['name', 'username'])
->search(trim($query));
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, thanks for this package! I was wondering how can I achieve this and is this possible?
https://laravel.com/api/8.x/Illuminate/Support/Traits/Conditionable.html
Here's how I imagine the code would look like
Beta Was this translation helpful? Give feedback.
All reactions