ÅÄÖ characters in Eloquent Sluggable
Robin Nilsson • August 23, 2019
In Sweden, we have three letters that might look weird to you: Å, Ä and Ö, so this post is mainly for Swedes.
Usually, you don't want to use these characters in, for example, slugs. Therefore most slug generators will translate Å to A, Ä to A and Ö to O.
I use the package eloquent-sluggable in my Laravel projects, which I love! However, this package does not generate slugs using the method above. Ö translates to OE, which is wrong.
1. Publish config
php artisan vendor:publish --provider="Cviebrock\EloquentSluggable\ServiceProvider"
2. Set slug helper as method
You'll find sluggable.php
in your config directory.
[
...
'method' => function($string) {
return Str::slug($string);
},
...
]