From 769f3818f378cbd01f91c86607360cc3b39430fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Sun, 7 May 2023 01:34:54 +0200 Subject: [PATCH] fixup! add class that handles model with slug --- src/PersistentData/Model/ModelWithSlug.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/PersistentData/Model/ModelWithSlug.php b/src/PersistentData/Model/ModelWithSlug.php index 2d69ebb..e691f26 100644 --- a/src/PersistentData/Model/ModelWithSlug.php +++ b/src/PersistentData/Model/ModelWithSlug.php @@ -20,16 +20,13 @@ abstract class ModelWithSlug extends Model public function getSlug(): string { - if ($this->slug === null) { - $this->slug = $this->generateSlug(); - } - return $this->slug; } - private function generateSlug(): string + public function generateSlug(): string { $slugSourceGetMethod = 'get' . str_replace('_', '', ucwords(static::$slugSource, '_')); - return Slugify::create()->slugify($this->$slugSourceGetMethod()); + $this->slug = Slugify::create()->slugify($this->$slugSourceGetMethod()); + return $this->slug; } }