'Laravel and package spatie/laravel-translatable -> Make search query for special character
I use the package Spatie/laravel-translatable to store my translated data in json in the database.
I have a column title :
{
"fr":"L\u2019\u00e9quipe",
"en":"Team",
"de":"Team"
}
As you can see, with the package, special characters are transformed into unicode.
When I want to search, it does not work (it's logical, because I'm looking for the word équipe but in the database it says \u00e9quipe)
$search = $request->get('search')
Events::where('title', 'LIKE', '%' . $search . '%')->published()->get();
How to search through Unicode for it to work?
Thank you
Solution 1:[1]
use
$this->attributes[$key] = json_encode($translations, JSON_UNESCAPED_UNICODE);
instead of
// $this->attributes[$key] = $this->asJson($translations);
in the Spatie\Translatable\HasTranslations trait
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Taha Elkholy |
