2
I have a column name
that belongs to the model Producer_BVU
, whose names are:
2M1J
A. Coelho
ÓRBITA
Bruno
When I command:
\App\Producer_BVU::orderBy('name', 'ASC')->get();
The output gets:
ÓRBITA
2M1J
A. Coelho
Bruno
Is there any way, preferably without modifying mysql charset settings, of in this query orderby
the accents are ignored?
Whose desired result is:
2M1J
A. Coelho
Bruno
ÓRBITA
It can be with some function of Laravel after the extraction of the data without problem, it doesn’t need to be soon in the call to the database, maybe even prefer.
My config/database settings for mysql:
...
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
...
Try to put it in the file
database.php
those instructions inmysql
-'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
– Diego Souza
I edited with these details @Diegosouza. But preface I would not like to touch here
– Hula Hula
And I’d like to move where? It can be with some function of Laravel after the extraction of the data.... Doing this is doing Order By twice because the first time didn’t work right...
– Diego Souza
Same if you run the query directly? Type by phpmyadmin?
– Guilherme Nascimento
@Hulahula this orderly field
name
was created in whichcollation
?– novic
Hello @Virgilionovic, went with
utf8_unicode_ci
, But I already did, I added to each item of the colection a Slug, and then I order for it. I’ve done it, but you can put the answer if you know another way– Hula Hula