eg-mohamed/referenceable
Referenceable is a Laravel package that adds customizable reference numbers to Eloquent models. It offers random, sequential, and template-based generation with placeholders like {YEAR} and {SEQ}, plus collision handling, validation, multi-tenancy, and Artisan commands.
{YEAR}, {MONTH}, {SEQ}) are configuration rather than code, you can ship format changes as a config/ops decision — useful when sales or a partner integration mandates a numbering convention late in a release cycle.uniqueness_scope = global | model | tenant plus a tenant column makes "unique per company" a config flag rather than a schema migration, which de-risks the multi-tenant milestone and lets you sequence it independently of the numbering work.php artisan referenceable:generate "App\Models\Order" --dry-run/--batch and validate --fix turn "we have 400k legacy rows with no reference" from an engineering project into a runbook item — a meaningful scope reduction when estimating a launch-readiness epic.01IOL) directly reduces mistyped references in support calls and manual data entry; that is a small but measurable CX lever you can defend in a prioritization review.Good fit when:
create/save), not via raw SQL bulk inserts or an external service.Look elsewhere (or build in-house) when:
insert(), queue workers writing raw SQL, third-party systems) — the trait won't fire.regenerateReference() and --fix are footguns here; you would need to wrap and restrict them.Diligence items to close before adoption:
MohamedSaid\ModelReference\ModelReference while the package is now referenceable (renamed from model-reference in v2.0.3). Expect namespace drift in blog posts and Stack Overflow answers; confirm the current namespace against composer.json and the actual release tag.To executives (one paragraph): Customers, support agents, and finance teams need short, quotable identifiers on orders, invoices, and tickets — today we would build that from scratch as custom code in every model. This MIT-licensed Laravel package provides it as configuration: prefixes, date-based templates, sequential numbering with reset periods, per-tenant uniqueness, and one-command backfill for existing records. Adopting it removes roughly a sprint of low-differentiation work from the launch path and makes future format changes a config change rather than a release. The trade-off is dependency risk: it is a small, single-maintainer, low-adoption package, so we will pin the version and keep it behind a thin internal wrapper so it can be replaced in a day if needed. We should not use it as the system of record for legally mandated invoice numbering without a finance/legal sign-off.
To engineering (framing): Treat it as a replaceable utility, not a framework. Add the HasReference trait, keep a DB unique() index on the column (and a composite index for tenant scope), and wrap all generation/regeneration calls in your own service class so call sites never touch the package namespace directly. Pin the version; do not use --all regeneration or --fix in production without a reviewed runbook. Benchmark sequential mode under realistic concurrency before using it for anything financial, and pre-approve a fallback plan (a ~200-line internal trait or a DB sequence) since the code surface is small. Budget roughly half a day for adoption plus a day of diligence on tests, concurrency, and the namespace/rename drift between model-reference and referenceable.
Bottom line: Worth a time-boxed spike for operational reference numbers on a Laravel product; not a safe foundation for regulated or high-concurrency sequential numbering. Expected value is "saves a sprint, costs a day of diligence, carries a small and easily-contained dependency risk."
How can I help you explore Laravel packages today?