I am using this package for slugs in my Laravel 5.5 app. I was upgrading from Laravel 4.2 and I followed upgrade instructions, so now I have this in my model:
public function sluggable()
{
return [
'slug' => [
'source' => ['id', 'title'],
'separator' => '-',
]
];
}
but my models don't read id
at all in the slug when creating.
Before when I'd save a model, I would have 123456-model
, and now I am getting just model
without prepended ID.
Does anyone know what the issue may be?
I have resolved the issue by setting the slug to null and then saving the model (only after the model was already in the DB).
$model = new Model(...);
...
$model->save(); // <-- initial DB insert so that model has ID
// resluggify
$model->slug = null;
$model->save();