mtvs/eloquent-hashids
Laravel package that integrates Hashids with Eloquent models, letting you hide sequential IDs behind short, unique hashids. Add the HasHashid trait to expose a hashid attribute, query models by hashid, and use hashids in route model binding while keeping your database keys unchanged.
/orders/x7Kp2 style routes without changing controllers, so it informs naming, versioning, and backward-compatibility commitments.Consider it when:
Look elsewhere when:
To executives: This is a low-cost security hygiene win. Today our URLs expose sequential database IDs, which reveals how many customers/orders exist and makes scraping trivial. This package hides those IDs in public-facing links in roughly a day of engineering, with no database changes and no downtime. It's a reversible obfuscation layer, not encryption — we should frame it as reducing casual exposure, not as a compliance control.
To engineering: It's a single trait (HasHashId) plus config for salt/length/alphabet. Hashids are computed on the fly from the integer PK, so there's no schema change, no extra column, no extra query, and route model binding resolves hashids back to models. Integration is contained to models and routes; rollback is deleting the trait. The trade-off to accept explicitly: hashids are reversible given the salt, so keep the salt out of client bundles and rotate it deliberately — rotating invalidates previously shared links. If we later need non-reversible or distributed IDs, we migrate to UUID/ULID, and this package is a clean intermediate step rather than a dead end.
How can I help you explore Laravel packages today?