There is already a popular package that handle slugs and its possible issues: https://github.com/cviebrock/eloquent-sluggable
It can handle uniqueness adding an id suffix to previously used slugs, detect if you want to overwrite soft-deleted slugs, and some other customs configs.