How to generate unique random value for each user in laravel and add it to database

前端 未结 8 1946
刺人心
刺人心 2020-12-29 08:44

I am developing a event organization website. Here when the user registers for an event he will be given a unique random number(10 digit), which we use to generate a barcode

8条回答
  •  自闭症患者
    2020-12-29 09:06

    You can use php's uniqid() function to generate a unique ID based on the microtime (current time in microseconds)

    Example:

    
    

    Output:

    56c3096338cdb
    

提交回复
热议问题