Create a unique username based on first letter of first name and entire last name in Laravel

Posted 1 month ago by beeInteractive

I have a database with users. One column for the first name, one for the last name. I need to generate the usernames based on the first name and the last name and need to follow this pattern:

first letter of first name only entire last name if the combination is not unique, then add a number at the end of the last name, increment on each new identical occurence.

How can I achieve this with eloquent and Laravel?

Thanks in advance!

Please sign in or create an account to participate in this conversation.