vendredi 29 janvier 2016

Laravel 5.1 - Generate a unique 10 alphanumeric character code upon save to database

I'm working in Laravel 5.1 and saving a gecko to a database (note that i will update my code soon when i'm on my break).

I have an idea floating around in my head that I would like to create a unique 10 character alphanumeric string to save to each gecko.

I know that I can generate random strings easily inside Laravel, and my plan was to add it in the controller and do a validation rule for it inside my model - but i didn't want it to flag an error to the screen that a random string couldn't be generated, as it should do all this behind the scenes and continue until it can create one.

Is there a proper practice into achieving something like this?

Thanks for any info, Andy



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire