Benua
Benua

Reputation: 269

Laravel search function case insensitive

I have a function that handles search requests from a search box. In SQL I have values with capital and with lower letters.

function search(Request $request){
    $shops = Shop::all ();
    $query = '%'.$request->input('search').'%';
    $goods = Good::where('name', 'LIKE', $query)->get();
    return view('filter2')->with(['goods' => $goods, 'shops' => $shops]);
}

Is it possible to make this search case insensitive without using raw queries?

Upvotes: 0

Views: 725

Answers (1)

georaldc
georaldc

Reputation: 1940

Not sure if you really need a Laravel answer but case sensitivity depends on the collation you are using. Is the table or column you are working with set to use a case-insensitive collation? If not, then that's probably why your queries are being treated as case sensitive.

Upvotes: 2

Related Questions