Monday, May 22, 2017

laravel search function case insensitive

So i have this function. It handles search request 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?

Thanks.



via Benua

Advertisement