Fix bangla slug problem in eloquent sluggable.

In laravel framework, there is a third party library for automatically generate slug for your eloquent model. It is by default works fine but when the source is Unicode Bangla text it will generate slug just like this -2,1,2,3,4,-6. You can solve this issue just following simple work.

First¬†add a file in the config folder name with sluggable.php, if you don’t have already it.

Now add a return array with method key like as below

return [
    'method' => function ($string, $separator) {
        return strtolower(preg_replace('/\s+/u', $separator, $string));

Just finished. Hope, your problem will be solved.

Share on :

Leave a Reply

− three = 4