在Laravel中使用波斯字符Slug

问题描述 投票:0回答:1

我正在使用Laravel,并且使用cviebrock / eloquent-sluggable为产品制造弹头

因此,当我使用英文标题时,效果很好,但是每当我使用波斯语时,例如“تست” slug都另存为英文翻译,例如“ tst”我改变慢跑的方法

     'method' => function ($string, $separator = '-') {
     if (is_null($string)) {
         return "";
     }

     // Remove spaces from the beginning and from the end of the string
     $string = trim($string);

     // Lower case everything
     // using mb_strtolower() function is important for non-Latin UTF-8 string | more info: 
     $string = mb_strtolower($string, "UTF-8");;

     // Make alphanumeric (removes all other characters)
     // this makes the string safe especially when used as a part of a URL
     // this keeps latin characters and arabic charactrs as well
     $string = preg_replace("/[^a-z0-9_\s-ءاأإآؤئبتثجحخدذرزسشصضطظعغفقكلمنهويةى]#u/", "", $string);

     // Remove multiple dashes or whitespaces
     $string = preg_replace("/[\s-]+/", " ", $string);

     // Convert whitespaces and underscore to the given separator
     $string = preg_replace("/[\s_]/", $separator, $string);

     return $string;
 },

但仍然相同

php laravel slug
1个回答
0
投票

我找到了解决方案

首先,您必须将此提供程序放入config / app.php

© www.soinside.com 2019 - 2024. All rights reserved.