I set my "slug" value in laravel so:
public function setTitleAttribute($value)
{
$this->attributes['title'] = $value;
$this->attributes['slug'] = str_slug($value);
}
This method works, but much elements at the moment has the same name and same generated slug, so I want to add additional content to slug, how can I do it? Can I do something like
public function setTitlePackAttribute($value, $key)
{
$this->attributes['title'] = $value;
$this->attributes['pack'] = $key;
$this->attributes['slug'] = str_slug($value . $key);
}
I want to generate slug from more sources...
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire