TitasGailius / nova-search-relations

This package allow you to include relationship columns into Laravel Nova search query.
Other
352 stars 33 forks source link

Introduce case-insensitive like search #11

Closed f-liva closed 5 years ago

f-liva commented 5 years ago

Changing the collation of MySQL is no longer a solution for searching insensitive cases with LIKE. The search field and search query must therefore be standardised in the casing.

TitasGailius commented 5 years ago

I don't really wanna do this because it's not consistent with the default search feature.

A better solution is to give more flexibility on how the compare query is constructed. Something like an easy way to override a specific method where you could add your own query logic:

example: ... inside the resource class:

    protected function applySearchQuery($query, $column, $search)
    {
        $query->orWhere(DB::raw("LOWER({$column})"), 'LIKE', '%' . strtolower($search) . '%');
    }
f-liva commented 5 years ago

Maybe this is a step further?

Anyway, is this a change you want to do you directly?

f-liva commented 5 years ago

Nothing here?

TitasGailius commented 5 years ago

I'll probably try to split the query applier into a separate method or something.

As a temporary solution, you may override the searchQueryApplier inside your base Resource class according to your needs.