twill
twill copied to clipboard
feat: add searchQuery method to controller for finer control over the search
Description
Sometimes we need to be able to customize how the search works in a controller to search in a relation, or maybe to run a specific search, or to run a search that uses indexes
Now we can do just that and it's compatible with searchColumns:
$this->setSearchColumns(['email', 'phone']);
$this->setSearchQuery(
fn (Builder $q, string $search) => $q
->orWhereHas('profile', fn (Builder $q) => $q
->where('first_name', 'like', "$search%")
->orWhere('last_name', 'like', "$search%")
)
);