Generate sequential running numbers for your Laravel application. Perfect for invoice numbers, order numbers, customer IDs, and any other sequential identifiers you need.
- π’ Sequential Generation - Automatic sequential number generation per type
- πΎ Database Persistence - Reliable state storage in your database
- π Reset Periods - Automatic reset (daily, monthly, yearly, or never)
- π Thread-Safe - Race condition protection with database transactions
- π’ Multiple Sequences - Separate sequences per type using scopes
- π― Custom Starting Numbers - Start sequences from any number
- π Range Management - Set maximum limits with exception handling
- π Date-Based Formats - Built-in date presenters for time-organized numbers
- ποΈ Preview Mode - Preview next numbers without incrementing
- π¦ Bulk Generation - Generate multiple numbers at once atomically
- βοΈ Configurable - Customize padding, formatting, and behavior
- π UUID Support - Built-in UUID support for running number records
- π·οΈ Native PHP Enums - Modern PHP 8.1+ enum support with Traitify
- π§ Extensible - Custom generators and presenters via contracts
- π Developer Friendly - Helper functions, facades, Eloquent trait, Artisan commands, and REST API
- π Event System - Built-in events for auditing and notifications
- π REST API - Optional HTTP endpoints for remote number generation
- π¦ Wide Compatibility - Laravel 9-12 & PHP 8.1-8.4
Install via Composer:
composer require cleaniquecoders/laravel-running-numberPublish and run migrations:
php artisan vendor:publish --tag="running-number-migrations"
php artisan migrateOptionally, publish the configuration:
php artisan vendor:publish --tag="running-number-config"π Detailed Guide: See the complete Installation Guide for more information.
use CleaniqueCoders\RunningNumber\Enums\Organization;
// Using the helper function
$number = running_number()
->type(Organization::PROFILE->value)
->generate();
// Output: PROFILE001use Illuminate\Database\Eloquent\Model;
class Invoice extends Model
{
protected static function booted()
{
static::creating(function ($invoice) {
$invoice->invoice_number = running_number()
->type('invoice')
->generate();
});
}
}
// Now every invoice automatically gets a sequential number
$invoice = Invoice::create([
'customer_id' => 1,
'amount' => 100.00,
]);
// invoice_number: INVOICE001use CleaniqueCoders\RunningNumber\Contracts\Presenter;
class CustomPresenter implements Presenter
{
public function format(string $type, int $number): string
{
return sprintf('%s-%04d', $type, $number);
}
}
$number = running_number()
->type('invoice')
->formatter(new CustomPresenter())
->generate();
// Output: INVOICE-0001π Learn More: Check out the Quick Start Guide and Common Scenarios for more examples.
Comprehensive documentation is available in the docs directory:
- Getting Started - Installation, quick start, and core concepts
- Configuration - Configuration options, types, enums, and models
- Usage - Helper functions, facades, model integration, and examples
- Advanced Features - Date formats, scopes, ranges, and more
- Development - Testing, contributing, and development setup
- Installation Guide
- Quick Start
- Common Scenarios
- Date-Based Formats
- Multiple Sequences
- Custom Starting Numbers
- Number Range Management
- Preview & Bulk Generation
- Upgrade Guide
- API Reference
composer testSee the Testing Guide for more information.
Please see CHANGELOG for more information on what has changed recently.
We welcome contributions! Please see our Contributing Guide for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.