Support the ongoing development of Laravel.io →
Input Database Eloquent
Last updated 2 years ago.
0

why do you want to generate an id? if it's to mask id's in an url you can use something like http://www.hashids.org/php/

it's better to use basic numeric id when using Laravel if you don't want to change a lot. (Relationships for example)

if you still need to generate your own id I suggest you use uuid v4, the collision (change that it generates the same id twice) is very low

example https://gist.github.com/dahnielson/508447

Last updated 2 years ago.
0

zenry said:

why do you want to generate an id? if it's to mask id's in an url you can use something like http://www.hashids.org/php/

it's better to use basic numeric id when using Laravel if you don't want to change a lot. (Relationships for example)

if you still need to generate your own id I suggest you use uuid v4, the collision (change that it generates the same id twice) is very low

example https://gist.github.com/dahnielson/508447

Thanks for comment, but UUID is too long for my system

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

nasaorc nasaorc Joined 19 Jun 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.