From 6fbe770bfd2f83476f47325cc6f6346326255d46 Mon Sep 17 00:00:00 2001 From: semenov Date: Thu, 22 Aug 2019 10:13:02 +0300 Subject: [PATCH] Fixed unique --- CHANGELOG.md | 4 ++++ src/YaSlugBehavior.php | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de2fefb..373327d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ CHANGELOG ============== +1.0.2 +--------------- + * Fixed unique + 1.0.1 --------------- * Updated diff --git a/src/YaSlugBehavior.php b/src/YaSlugBehavior.php index 990763e..ff690de 100644 --- a/src/YaSlugBehavior.php +++ b/src/YaSlugBehavior.php @@ -110,7 +110,7 @@ public function getValue($event) { if ($last = $this->owner->find()->orderBy('id DESC')->limit(1)->one()) { - $slug = $slug . '-' . $last->id; + $slug = $slug . '-' . substr(md5(microtime()), 0, 5); return YaSlugHelper::slugify($slug); } } @@ -122,7 +122,7 @@ public function getValue($event) { if ($last = $this->owner->find()->orderBy('id DESC')->limit(1)->one()) { - $slug = $slug . '-' . $last->id; + $slug = $slug . '-' . substr(md5(microtime()), 0, 5); return YaSlugHelper::slugify($slug); } }