I would opt for the validation loop. I don't think this will require a lot of DB request, most of the time the hash will be unique, so the chances that the validation would fail are limited.
8 digits string ? you can only save: 10^8 files ? So why don't you using auto increment ?
Can you save 23 or more characters ? then the php
way to archive this is uniqid() :)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community