Ad

Ignore Accented Chars Eloquent Query

I'm trying to query registers with fields that can contain accents like à á ä (Catalan language). When I search 'alex' it does not returns 'Àlex' register.

I'm using laravel 5.5, mysql 5.7 and PHP 7.0.

Search code:

$client = new Client();
$client = $client->newQuery();

if ($request->has('name') && !empty($name = $request->input('name'))) 
{
    $client->where('name', 'LIKE', "%$name%");
}

return $client->get();

How can I query registers without distinguishing accents and case of the chars using Eloquent and Laravel?

Ad

Answer

The problem was the configuration of test. I was using sqlite instead of mysql. Thanks for the answers. The default configuration of laravel for mysql works:

config/database.php

'mysql' => [
    ...
    'charset' => 'utf8mb4',
    'collation' => 'utf8mb4_unicode_ci',
    ...
]
Ad
source: stackoverflow.com
Ad