2

I'm not able to use the pgsql extension unaccent while trying to retrieve records from a database.

I set up a dynamic search in my application that sends, with Ajax, what the user types in a field, and also what field was selected. I replace every accent in the string with a javascript function before sending it to my controller.

My problem is that I don't know how to make postgre understand that it should ignore accents.

I tried to use Eloquent's whereRaw to use the unaccent (that I activated) function, with no success.

->whereRaw("unaccent(".$request->field.") ILIKE '".$request->search."'")
Skery
  • 57
  • 1
  • 8

1 Answers1

2

Open PostgreSQL, select database and do this command:

CREATE EXTENSION unaccent;

$query->whereRaw("unaccent(".$request->field.") ilike unaccent('%".$request->search."%')");
Dharman
  • 30,962
  • 25
  • 85
  • 135
Vadims
  • 21
  • 2