We use cookies for commenting and analytics. Share on Facebook, Linkedin, TwitterWhen we are working with users or posts, one of the features that we often need is generating usernames or slugs.

Let’s see how can we use a very simple solution: generating incremental usernames.

With a very simple regex pattern, we can easily track the similar usernames in the database, and add, or increment a numeric suffix to the username.

However, when you need a more complex solution for slugs or usernames, you might extend this solution or pull in a package.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners