How to generate unique user id using php?

I am developing an app using Laravel which will have a functionality to register user. I want to provide customized unique id to every user [ie: User_id = SM129]. Userid will have following features: 1] User id will be auto-generated while registering. 2] Auto-generated user id should be Check to a database for its uniqueness.

Currently, I am using following code to generated unique user id based on current date. but there is a chance of duplicity on a username with this. Please help



Chủ Đề