momenoor / filament-serial
A Filament V3 form macro for `TextInput` that allows you to easily format and manage serial numbers with optional prefixes, suffixes, separators, and padded digits.
Requires
- php: ~8.1|~8.2|~8.3|~8.4
- akaunting/laravel-money: ^1.2|^2.0|^3.0|^4.0|^5.2|^6
- filament/tables: ^3.0
- illuminate/contracts: ^10.0|^11|^12.0
- spatie/laravel-package-tools: ^1.15.0
Requires (Dev)
- larastan/larastan: ^2.7.0
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.9
- orchestra/testbench: ^8.0|^10.0
- pestphp/pest: ^2.0|^3.7
- pestphp/pest-plugin-arch: ^2.0|^3.0
- pestphp/pest-plugin-laravel: ^2.0|^3.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0|^2.0
- phpstan/phpstan-phpunit: ^1.0|^2.0
This package is auto-updated.
Last update: 2025-05-08 00:22:59 UTC
README
A Filament V3 form macro for TextInput
that allows you to easily format and manage serial numbers with optional prefixes, suffixes, separators, and padded digits.
✨ Features
- Format serial numbers in Filament forms.
- Support for:
- Prefix and/or suffix
- Custom separator
- Fixed digit zero-padded numeric part
- Automatically formats on blur and focus
- Saves only numeric part to database
- Built-in Alpine.js interactivity
- Simple integration with Filament
TextInput
📦 Installation
You can install the package via Composer:
composer require momenoor/filament-serial
This package auto-registers itself. No need to publish anything.
⚙️ Usage
use Filament\Forms\Components\TextInput; TextInput::make('serial_number') ->label('Serial Number') ->serial( prefix: 'INV', // Optional string or Closure suffix: 'UAE', // Optional string or Closure separator: '-', // Default is "-" length: 6 // Default is 8 );
Example
Interaction | Value Example |
---|---|
On blur | INV-000123-UAE |
On focus | 123 |
In database | 000123 |
🛠 Parameters
Parameter | Type | Description |
---|---|---|
prefix |
string|Closure | Text before the numeric part |
suffix |
string|Closure | Text after the numeric part |
separator |
string | String between segments (default: - ) |
length |
int | Number of digits in the numeric part (default: 8 ) |
✅ Compatibility
- Laravel 10+
- Filament 3.x
- PHP 8.1+
📄 Changelog
Please see CHANGELOG for more information on recent changes.
🤝 Contributing
Please see CONTRIBUTING for details.
🔐 Security
If you discover any security-related issues, please review the security policy.
🙌 Credits
📜 License
The MIT License (MIT). Please see LICENSE for more information.