I do not know why, but as soon as I save a post with Laravel Backpack, the data stored with a special character is transformed.
Héllo
becomes H\u00e9llo
It is a problem. I checked my data mysql and everything seems ok (I use homestead).
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci'
The customer today want a search feature. And obviously, it does not work with searches on special characters ...
Here is my code for the search:
public function searchNav(Request $request)
{
$search = $request->get('search');
$buildings = Building::where('title', 'LIKE', '%' . $search . '%')->orWhere('city', 'LIKE', '%' . $search . '%')->published()->get();
$activity = Activity::where('title', 'LIKE', '%' . $search . '%')->orWhere('city', 'LIKE', '%' . $search . '%')->published()->get();
// Create a new collection and merge elements
$all = new Collection();
$all = $all->merge($buildings);
$all = $all->merge($circuit);
$all = $all->sortByDesc('updated_at');
$this->data['items'] = $all->all();
return view('pages.search-nav-results', $this->data);
}
How do I say to my request that if I search for a word that says "Héllo", it finds me the elements stored in my database H\u00e9llo
?
Thanks for your help!