Laravel unique slug generator
1 min readJun 7, 2020
Want to generate unique slug in Laravel? Its pretty easy. Lets try.
First of all you should have a `slug` column in your Model. Suppose you have Post model. add this code inside model class,
Now you can call slugify method anywhere using post object for generate unique slug. Assume, you want to store a post with slug. in PostController you can easily generate slug and store into database.