Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
This is gonna happen at rendering time, not storing time. Just keep storing as integer but format the string differently
-
potata14776yWell, that really depends.
A) You store them as Auto increment - then on display time - you modify to add pads (`0` to the start). This can be done in model with getIdAttribute.
B) You store the integer with mutation manually and hope for the best to avoid conflicts with big data. Then all you need to do is format it before sending and vuolia - you have what you need.
IMHO: I'd go for the A. -
@beegC0de @potata that's exactly what I wanted to avoid doing (option A). What I'm doing will be used in a lot of different places for a lot of different things and I didn't want to do that every-single-time a need to select something from that table.
I just hope laravel comes up with a better solution for this. -
It is almost certainly a cleaner solution than coming up with a different way to represent integers in storage
Related Rants
Does anyone, that works/has worked with laravel know how to give id a minimum length?
For example, instead of 1 I would want 000001, 10 would be 000010, and so on.
I know uuid does something similar, but it's not exactly what I want. Also, I had a bad experience with uuid, where I wanted to delete the field but it would still show up every time I migrated 🙃 but it wasn't it the migration file 🙃 so now I try to avoid using it 🙃
question
uuid
laravel
id minimum length