Compare commits
2 Commits
00e77aef62
...
1ef83ab57b
Author | SHA1 | Date | |
---|---|---|---|
1ef83ab57b | |||
769f3818f3 |
@ -20,18 +20,13 @@ 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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -113,10 +113,6 @@ 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']);
|
||||
@ -129,7 +125,8 @@ class PersistentDataManager implements IPersistentDataManager
|
||||
}
|
||||
} else {
|
||||
if ($model instanceof ModelWithSlug) {
|
||||
$modified['slug'] = $this->generateUniqueSlug($model, $modified['slug']);
|
||||
$slug = $model->generateSlug();
|
||||
$modified['slug'] = $this->generateUniqueSlug($model, $slug);
|
||||
}
|
||||
|
||||
$modify->fill($modified);
|
||||
|
Loading…
Reference in New Issue
Block a user