Compare commits
1 Commits
1ef83ab57b
...
00e77aef62
Author | SHA1 | Date | |
---|---|---|---|
00e77aef62 |
@ -20,13 +20,18 @@ abstract class ModelWithSlug extends Model
|
||||
|
||||
public function getSlug(): string
|
||||
{
|
||||
if ($this->slug === null) {
|
||||
$this->slug = $this->generateSlug();
|
||||
var_dump('getSlug called');
|
||||
var_dump($this->slug);
|
||||
}
|
||||
|
||||
return $this->slug;
|
||||
}
|
||||
|
||||
public function generateSlug(): string
|
||||
private function generateSlug(): string
|
||||
{
|
||||
$slugSourceGetMethod = 'get' . str_replace('_', '', ucwords(static::$slugSource, '_'));
|
||||
$this->slug = Slugify::create()->slugify($this->$slugSourceGetMethod());
|
||||
return $this->slug;
|
||||
return Slugify::create()->slugify($this->$slugSourceGetMethod());
|
||||
}
|
||||
}
|
||||
|
@ -113,6 +113,10 @@ class PersistentDataManager implements IPersistentDataManager
|
||||
}
|
||||
}
|
||||
|
||||
var_dump($original);
|
||||
var_dump($modified);
|
||||
var_dump($diff);
|
||||
|
||||
if (count($modified) > 0) {
|
||||
if ($model instanceof ModelWithSlug && isset($modified['slug'])) {
|
||||
$modified['slug'] = $this->generateUniqueSlug($model, $modified['slug']);
|
||||
@ -125,8 +129,7 @@ class PersistentDataManager implements IPersistentDataManager
|
||||
}
|
||||
} else {
|
||||
if ($model instanceof ModelWithSlug) {
|
||||
$slug = $model->generateSlug();
|
||||
$modified['slug'] = $this->generateUniqueSlug($model, $slug);
|
||||
$modified['slug'] = $this->generateUniqueSlug($model, $modified['slug']);
|
||||
}
|
||||
|
||||
$modify->fill($modified);
|
||||
|
Loading…
Reference in New Issue
Block a user