twill icon indicating copy to clipboard operation
twill copied to clipboard

feat: add searchQuery method to controller for finer control over the search

Open Tofandel opened this issue 1 year ago • 0 comments

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%")
            )
        );

Tofandel avatar Jun 13 '24 19:06 Tofandel