-1

I am facing a problem where I tried to query set of data from database using Laravel 7. Below is my code, I tried to use ILIKE but the browser return an error, how can I fix this? or any other ways that I can use?

$hawker = Hawker::withTrashed();

if($request->name){
        $hawker = $hawker->where('name', 'ILIKE', '%'.$request->name.'%');
        }

    $hawker = $hawker->paginate($request->sizePerPage);

    return response()->json($hawker, Response::HTTP_OK);

The query just to ignore any uppercase or lowercase whether if the data in database example like 'Chicken', but my query is chicken , it will still return the data

  • AFAIK `ilike` is Postgres only. You didn't mention either the database you are using or the error you got, but I'm guessing it is *not* Postgres, and the error was related to that. In any case, searching for "*laravel where ignore case*" turns up pleny of answers: https://stackoverflow.com/questions/51497890/how-to-search-case-insensitive-in-eloquent-model, https://stackoverflow.com/questions/21213490/laravel-eloquent-ignore-casing, ... – Don't Panic May 25 '22 at 07:57
  • Does this answer your question? [How to search case insensitive in Eloquent model](https://stackoverflow.com/questions/51497890/how-to-search-case-insensitive-in-eloquent-model) – Don't Panic May 25 '22 at 07:57

0 Answers0