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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners