public function slug(Model $model, $force = false)
{
$this->setModel($model);
$attributes = [];
foreach ($this->model->sluggable() as $attribute => $config) {
if (is_numeric($attribute)) {
$attribute = $config;
$config = $this->getConfiguration();
} else {
$config = $this->getConfiguration($config);
}
$slug = $this->buildSlug($attribute, $config, $force);
$this->model->setAttribute($attribute, $slug);
$attributes[] = $attribute;
}
return $this->model->isDirty($attributes);
}
/** * @param \Illuminate\Database\Eloquent\Model $model * @param string $event * @return boolean|null */ protected function generateSlug(Model $model, $event) { // If the "slugging" event returns a value, abort if ($this->fireSluggingEvent($model, $event) !== null) { return; } $wasSlugged = $this->slugService->slug($model); $this->fireSluggedEvent($model, $wasSlugged); }