I want to create a filter. But I am facing case-sensitive problem. I have tried with my below code. But It didn’t work. I have got error ‘call undfiend lcase’.
$type = strtolower($type); $name = strtolower($name); $users = DB::table('daftar.bank_list AS uc') ->leftJoin('users.users as u','u.bank_id','=','uc.id') ->when($type, function ($query, $type) { return $query->where('LCASE'('uc.type'), $type); }) ->when($name, function ($query, $name) { return $query->where('LCASE'('uc.name'), $name); }) ->get();
My database is Postgresql.
Advertisement
Answer
Try this:
$type = strtolower($type); $name = strtolower($name); $users = DB::table('daftar.bank_list AS uc') ->leftJoin('users.users as u','u.bank_id','=','uc.id') ->when($type, function ($query, $type) { return $query->where('uc.type','ILIKE', '%'.$type.'%'); }) ->when($name, function ($query, $name) { return $query->where('uc.name','ILIKE', '%'.$name.'%'); }) ->get();
You can search by ILIKE
query.