I am using Laravel 8 and use cviebrock/eloquent-sluggable
to make slug for products
so it works well when I use english title but whenever I use Persian for example "???" slug save as a english translate like this "tst" I change method of sluggable
after that method in config/sluggable
change
'method' => function($string, $separator = '-')
{
$_transliteration = array(
'/?|?|?/' => 'ae',
'/?|?/' => 'oe',
'/ü/' => 'ue',
'/?/' => 'Ae',
'/ü/' => 'Ue',
'/?/' => 'Oe',
'/à|á|?|?|?|?|ā|?|?|ǎ/' => 'A',
'/à|á|a|?|?|?|ā|?|?|ǎ|a/' => 'a',
'/?|?|?|?|?/' => 'C',
'/?|?|?|?|?/' => 'c',
'/D|?|?/' => 'D',
'/e|?|?/' => 'd',
'/è|é|ê|?|ē|?|?|?|ě/' => 'E',
'/è|é|ê|?|ē|?|?|?|ě/' => 'e',
'/?|?|?|?/' => 'G',
'/?|?|?|?/' => 'g',
'/?|?/' => 'H',
'/?|?/' => 'h',
'/ì|í|?|?|?|ī|?|ǐ|?|?/' => 'I',
'/ì|í|?|?|?|ī|?|ǐ|?|?/' => 'i',
'/?/' => 'J',
'/?/' => 'j',
'/?/' => 'K',
'/?/' => 'k',
'/?|?|?|?|?/' => 'L',
'/?|?|?|?|?/' => 'l',
'/?|?|?|?/' => 'N',
'/?|ń|?|ň|?/' => 'n',
'/ò|ó|?|?|ō|?|ǒ|?|?|?|?/' => 'O',
'/ò|ó|?|?|ō|?|ǒ|?|?|?|?|o/' => 'o',
'/?|?|?/' => 'R',
'/?|?|?/' => 'r',
'/?|?|?|?|?/' => 'S',
'/?|?|?|?|?|?/' => 's',
'/?|?|?|?/' => 'T',
'/?|?|?|?/' => 't',
'/ù|ú|?|?|ū|?|?|?|?|?|ǔ|ǖ|ǘ|ǚ|ǜ/' => 'U',
'/ù|ú|?|?|ū|?|?|?|?|?|ǔ|ǖ|ǘ|ǚ|ǜ/' => 'u',
'/Y|?|?/' => 'Y',
'/y|?|?/' => 'y',
'/?/' => 'W',
'/?/' => 'w',
'/?|?|?/' => 'Z',
'/?|?|?/' => 'z',
'/?|?/' => 'AE',
'/?/' => 'ss',
'/?/' => 'IJ',
'/?/' => 'ij',
'/?/' => 'OE',
'/?/' => 'f'
);
$quotedReplacement = preg_quote($separator, '/');
$merge = array(
'/[^sp{Zs}p{Ll}p{Lm}p{Lo}p{Lt}p{Lu}p{Nd}]/mu' => ' ',
'/[sp{Zs}]+/mu' => $separator,
sprintf('/^[%s]+|[%s]+$/', $quotedReplacement, $quotedReplacement) => '',
);
$map = $_transliteration + $merge;
unset($_transliteration);
return preg_replace(array_keys($map), array_values($map), $string);
}
the error i have is
LogicException : Your configuration files are not serializable.
what's the solution?
question from:https://stackoverflow.com/questions/65651278/use-persian-characters-as-slug-in-laravel