tonviet712
2 months ago
481
8
Laravel

Generate unique 8 characters, better solution beside Str::random(8) ?

Posted 2 months ago by tonviet712

I need to store to DB the code which is 8 characters and unique

Now my solution is $code = Str::random(8). But Str::random is not unique at all, so I need to check before to create. Can I have better solution? Thanks in advance

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