diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 1ff858c..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,10 +0,0 @@ -# Changelog - -## 1.2.0 - 2017-07-07 -- add `maximumLength(255)` - -## 1.1.0 - 2017-07-07 -- add `generateSlugOnCreate(false)` and `generateSlugOnUpdate(false)` - -## 1.0.0 - 2017-07-07 -- Initial release diff --git a/src/Arabify.php b/src/Arabify.php deleted file mode 100644 index 175a603..0000000 --- a/src/Arabify.php +++ /dev/null @@ -1,31 +0,0 @@ -app->runningInConsole()) { - - $this->publishes([ - __DIR__.'/../config/arabify.php' => config_path('arabify.php'), - ], 'config'); - } +// if ($this->app->runningInConsole()) { +// +// $this->publishes([ +// __DIR__.'/../config/arabify.php' => config_path('arabify.php'), +// ], 'config'); +// } } /** diff --git a/src/HasSlug.php b/src/HasSlug.php index 3628c35..ea2be6f 100644 --- a/src/HasSlug.php +++ b/src/HasSlug.php @@ -104,12 +104,12 @@ protected function generateNonUniqueSlug() { $slug = $this->getSlugSourceString(); // Given We Have Function From Config - $slugger = config('arabify.slug'); +// $slugger = config('arabify.slug'); // If We Don't Have It Use The Arabify - $slugger = $slugger ?: 'arabify'; +// $slugger = $slugger ?: 'arabify'; - return call_user_func($slugger,$slug, $this->slugOptions->slugSeparator); + return $this->arabify($slug, $this->slugOptions->slugSeparator); } /** @@ -207,4 +207,24 @@ private function checkUpdatingSlug($slug) // unique slug needed return false; } + + protected function arabify($title = null, $separator = "-") + { + $title = trim($title); + $title = mb_strtolower($title, 'UTF-8'); + + $title = str_replace('‌', $separator, $title); + + $title = preg_replace( + '/[^a-z0-9_\s\-اآؤئبپتثجچحخدذرزژسشصضطظعغفقكکگلمنوةيإأۀءهی۰۱۲۳۴۵۶۷۸۹٠١٢٣٤٥٦٧٨٩]/u', + '', + $title + ); + + $title = preg_replace('/[\s\-_]+/', ' ', $title); + $title = preg_replace('/[\s_]/', $separator, $title); + $title = trim($title, $separator); + + return $title; + } }