Download the PHP package mawuva/laravel-serial-sequence without Composer

On this page you can find all versions of the php package mawuva/laravel-serial-sequence. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-serial-sequence

Laravel Serial Sequence

A flexible, transactional, and extensible serial number generator for Laravel.

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Laravel Serial Sequence provides a robust solution for generating unique serial numbers with automatic incrementation based on series, year, and month periods. Perfect for invoices, orders, tickets, and any business documents requiring sequential numbering with period-based resets.

Features

Installation

You can install the package via composer:

You can publish and run the migrations with:

You can publish the config file with:

You can publish both migrations and config with:

Database Setup

1️. Option "Snippet / Migration Example"

Copy-paste this ready-to-use migration snippet into your migration file:

Advantages:

2️. Option "Trait Auto Add Columns" (Recommended)

Use the built-in HasSerialColumns trait for cleaner migrations:

Advantages:

The addSerialColumns method automatically creates:

Usage

Basic Model Setup

Add the HasSerialSequence trait and implement the HasSerial contract:

Required Methods

When implementing the HasSerial contract, you must define:

serialSerie(): string

setSerialAttributes(SerialData $data): void

Multiple Model Examples

Creating Records with Serial Numbers

Query Scopes

The package provides powerful query scopes for filtering:

Advanced Examples

How It Works

Serial Number Format

The package generates serial numbers in the format: {SERIE}-{YEAR}-{MONTH}-{NUMBER}

Example: ORD-2024-02-0001

Automatic Reset

Serial numbers automatically reset to 1 when:

This ensures clean separation between different periods and document types.

Database Structure

The package uses two main tables:

  1. serial_sequences - Tracks the last number used for each series/period combination
  2. Your model tables - Store the actual serial data

Transaction Safety

All serial number generation happens within database transactions to prevent:

Configuration

Publishing the Config File

Publish the configuration file to customize the serial number format:

This will create config/serial-sequence.php with the default settings.

Configuration Options

Understanding the Format

With the default configuration, serial numbers are generated as:

Example with defaults:

Custom Format Examples

Compact Format

Result: ORD2024020001

Slash-Separated Format

Result: ORD/2024/02/00001

With Prefix

Result: COMPANY|ORD-24-02-000123

Advanced Configuration

Dynamic Prefix Resolver

You can set a custom prefix resolver that receives the model instance:

Environment-Based Configuration

Different formats for different environments:

Testing

FAQ

Q: Can I use custom serial formats?

A: Yes! Configure the serial_format in the config file to match your needs.

Q: How do I handle multiple document types?

A: Use different series identifiers for each document type (e.g., 'ORD', 'INV', 'TICKET').

Q: Are serial numbers guaranteed to be unique?

A: Yes, the package uses database constraints and transactions to ensure uniqueness.

Q: Can I manually set serial numbers?

A: While possible, it's recommended to let the package handle generation automatically.

Q: What happens if I delete records?

A: Serial numbers are not reused. The sequence continues from the last used number.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-serial-sequence with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^11.0||^12.0|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mawuva/laravel-serial-sequence contains the following files

Loading the files please wait ...