Download the PHP package welman91/filament-record-number-generator without Composer
On this page you can find all versions of the php package welman91/filament-record-number-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download welman91/filament-record-number-generator
More information about welman91/filament-record-number-generator
Files in welman91/filament-record-number-generator
Package filament-record-number-generator
Short Description Configurable auto-generate record number for Filament
License MIT
Homepage https://github.com/welman91/filament-record-number-generator
Informations about the package filament-record-number-generator
Filament Record Number Generator
Configurable auto-numbering for any Eloquent model in Filament (v4, v5) . Supports patterns like INV-2026-0001, PO/{branch}/{sequence}, per-tenant sequences, fiscal year resets, gap-free mode, and prefix/suffix rules.
Installation
Add the package to your Laravel project:
Publish and run the migrations:
Optionally publish the config file:
Setup
1. Register the Plugin
Add the plugin to your Filament panel provider:
2. Add the Trait to Your Models
Add HasNumbering to any model that needs auto-numbering:
3. Create a Numbering Sequence
Navigate to Settings > Numbering Sequences in your Filament panel and create a sequence, or insert one directly:
Now every time an Invoice is created, the invoice_number attribute is automatically filled (e.g. INV-2026-0001, INV-2026-0002, ...).
Pattern Tokens
| Token | Example Output | Description |
|---|---|---|
{sequence} |
0001 |
Zero-padded sequence (default 4 digits) |
{sequence:N} |
000001 |
Zero-padded to N digits |
{year} |
2026 |
4-digit year |
{year:2} |
26 |
2-digit year |
{month} |
04 |
Zero-padded month |
{day} |
07 |
Zero-padded day |
{prefix} |
INV- |
Value from the sequence's prefix column |
{suffix} |
-A |
Value from the sequence's suffix column |
{attribute:name} |
Acme |
Model attribute (supports dot notation for relations) |
Example Patterns
| Pattern | Output |
|---|---|
INV-{year}-{sequence:4} |
INV-2026-0001 |
PO/{attribute:branch.code}/{sequence:5} |
PO/HQ/00001 |
{prefix}{year:2}{month}-{sequence:3}{suffix} |
CR-2604-001-A |
REC-{sequence:6} |
REC-000001 |
Custom Token Aliases
You can define custom token names that map to built-in resolvers, either via the admin UI or in the custom_tokens JSON column:
Custom Token Resolvers
Create a class implementing TokenResolver for completely custom logic:
Register it in config/filament-record-number-generator.php:
Then use {dept} in your patterns.
Reset Frequency
| Frequency | Behavior |
|---|---|
never |
Counter never resets — continuous numbering |
yearly |
Resets at the start of each fiscal year |
monthly |
Resets at the start of each month |
daily |
Resets at the start of each day |
Fiscal Year
When reset_frequency is yearly, the fiscal_year_start_month determines when the year rolls over:
1(January) — standard calendar year4(April) — fiscal year runs Apr–Mar (e.g. Jan 2026 belongs to fiscal year 2025)7(July) — fiscal year runs Jul–Jun
Gap-Free Mode
When is_gap_free is true, the package uses database row-level locking (SELECT ... FOR UPDATE) to guarantee no gaps in the sequence. The counter increment and model save happen within the same transaction — if the save fails, the counter rolls back.
Trade-off: Gap-free mode serializes concurrent requests for the same sequence. Use it only when regulatory or business requirements demand unbroken sequences (e.g. invoice numbers).
When is_gap_free is false (default), an atomic increment is used. Gaps may occur if a model creation fails after the counter is incremented, but throughput is higher.
Per-Tenant Isolation
Each numbering sequence is scoped by company_id. Two companies with the same sequence pattern maintain independent counters:
- Company A:
INV-2026-0001,INV-2026-0002, ... - Company B:
INV-2026-0001,INV-2026-0002, ...
Set company_id to null for a global sequence shared across all tenants.
Manual Override
If a model's numbered attribute is already filled before creation, the trait skips auto-generation. This allows manual number entry when needed:
Programmatic Usage
Generate a Number
Preview the Next Number
Returns what the next number will be without consuming a counter value:
On the Model
Events
The NumberGenerated event is dispatched after each number is generated:
Plugin Configuration
| Method | Description |
|---|---|
sequenceResource(false) |
Disable the Numbering Sequences resource in the panel |
navigationGroup('Admin') |
Change the navigation group |
Config File
After publishing, the config is at config/filament-record-number-generator.php:
| Key | Default | Description |
|---|---|---|
default_pattern |
{prefix}{year}-{sequence:4}{suffix} |
Default pattern for new sequences |
default_reset_frequency |
yearly |
Default reset frequency |
default_fiscal_year_start_month |
1 |
Default fiscal year start |
default_gap_free |
false |
Default gap-free mode |
navigation_group |
Settings |
Filament navigation group |
custom_resolvers |
[] |
Custom token resolver classes |
Localization
The package ships with English and Arabic translations. Publish them to customize:
Testing
License
MIT
All versions of filament-record-number-generator with dependencies
filament/filament Version ^5.0
spatie/laravel-package-tools Version ^1.15.0