willvincent/laravel-unique
willvincent/laravel-unique provides a simple trait for generating unique values on Eloquent models, making it easy to assign distinct IDs, codes, or tokens to records with minimal configuration in any Laravel application.
exists() / unique() validation with extra constraints (tenant scoping, soft-delete awareness, status filters) is commodity plumbing. Adopting a package here is a straightforward "buy" decision — it removes hand-rolled rule classes that tend to drift between teams and features.exists() check. That class of defect means a validation rule can silently accept or reject the wrong records — a data-integrity risk, not a cosmetic one. Treat it as a "patch now, test the scenario" item rather than a routine dependency bump.exists() rules) in our own test suite — validation bugs are cheap to prevent and expensive to detect in production.Consider adopting when:
exists() / unique() rules that need additional where constraints — per-tenant uniqueness, "must belong to this account," active-record-only checks.Look elsewhere or hold when:
orWhere groups, joins), or behavior the package doesn't document.To executives: This is a small, low-cost dependency that removes custom validation code from our codebase and makes "does this record exist and is it ours?" checks consistent across features. It is not a platform bet. The tradeoff is routine third-party dependency risk, which we mitigate by pinning the version and covering the behavior with our own tests. Recommendation: adopt narrowly in the surfaces we're already building, with a dependency-register entry and a review at the next dependency audit.
To engineering: Release 1.2 fixes constraint fields being misapplied in one of the exists() checks — a correctness bug, not a feature. Concretely: upgrade, then add a regression test that reproduces a constrained exists() rule (e.g., record exists but belongs to a different tenant) so we fail loudly if this ever regresses. Keep the version pinned, review the diff before merging, and flag if the package's test coverage or release cadence looks thin — in that case we fall back to a local rule class, which is a few hours of work.
Bottom line: Worth adopting for constrained database validation, with a pin, a regression test, and a short spike before we rely on it in critical paths.
How can I help you explore Laravel packages today?