cviebrock / eloquent-sluggable

Easy creation of slugs for your Eloquent models in Laravel
MIT License
3.88k stars 461 forks source link

Slugging with Laravel Nova #602

Closed mik3lov3st3ch closed 10 months ago

mik3lov3st3ch commented 10 months ago

Thanks Colin for that useful Laravel component! It´s a great help... One issue though in combination with Laravel Nova: When a new entity for a model is created, the slug is not created. It looks like the "saving" or "saved" lifecycle hooks are not called by Nova and therefore the slug isn´t created.

Steps to reproduce:

Result: The new entity is created but the sluggable field is not filled. If I create a model via a laravel service, a factory or tinker, the sluggable field is filled as it should be.

mik3lov3st3ch commented 10 months ago

Ok, it was my fault - all events are fired as expected. BTW one side note on switching the default event from "saving" to "saved": In my case the slug fields are set to "not nullable" in the database, which would lead to exceptions if a new entity is stored (cause the slug field doesn´t exist on the first save). I´m sure you know about that possible issue - only wanted to mention it.

mik3lov3st3ch commented 10 months ago

Closed...

cviebrock commented 10 months ago

Glad to have helped! 😉

What did the problem end up being? That way, anyone else with the same issue that searches and lands here will get the benefit of your experience!

mik3lov3st3ch commented 10 months ago

It was simply a stupid mistake :) I've set a field as sluggable that was not set as required in Nova (even not shown). As no error was thrown (slug is simply null) I ran in the wrong direction assuming that the saving events might not be fired. Time for weekend 😆