Skip to content

Commit

Permalink
Edit The Place Of Arabify Function
Browse files Browse the repository at this point in the history
  • Loading branch information
zymawy committed Feb 13, 2019
1 parent fd41a27 commit d6a6095
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 50 deletions.
10 changes: 0 additions & 10 deletions CHANGELOG.md

This file was deleted.

31 changes: 0 additions & 31 deletions src/Arabify.php

This file was deleted.

12 changes: 6 additions & 6 deletions src/ArabifyServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ class ArabifyServiceProvider extends ServiceProvider
*/
public function boot()
{
if ($this->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');
// }
}

/**
Expand Down
26 changes: 23 additions & 3 deletions src/HasSlug.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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;
}
}

0 comments on commit d6a6095

Please sign in to comment.