PHPackages                             virusphp/autonumbering - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. virusphp/autonumbering

ActiveLibrary[Database &amp; ORM](/categories/database)

virusphp/autonumbering
======================

Laravel package to create autonumber for Eloquent model

v1.5(1y ago)1541MITPHP

Since Nov 23Pushed 1y ago1 watchersCompare

[ Source](https://github.com/virusphp/laravel-autonumbering)[ Packagist](https://packagist.org/packages/virusphp/autonumbering)[ Docs](https://github.com/virusphp/autonumbering)[ RSS](/packages/virusphp-autonumbering/feed)WikiDiscussions main Synced today

READMEChangelog (6)Dependencies (3)Versions (7)Used By (0)

Laravel AutoNumber
==================

[](#laravel-autonumber)

Laravel package to create autonumber for Eloquent model

Installation
============

[](#installation)

You can install the package via composer:

```
composer require virusphp/autonumbering

```

Register the ServiceProvider in `config/app.php`

```
'providers' => [
    // ...
	Virusphp\AutoNumber\AutoNumberServiceProvider::class,
],
```

Publish the default configuration

```
php artisan vendor:publish --provider='Virusphp\AutoNumber\AutoNumberServiceProvider'

```

Running migration

```
php artisan migrate

```

Usage
=====

[](#usage)

Your Eloquent models should use the `Virusphp\AutoNumber\AutoNumberTrait` trait

The trait contains an abstract method `getAutoNumberOptions()` that you must implement yourself.

```
use Virusphp\AutoNumber\AutoNumberTrait;

class Order extends Model
{
    use AutoNumberTrait;

    /**
     * Return the autonumber configuration array for this model.
     *
     * @return array
     */
    public function getAutoNumberOptions()
    {
        return [
            'order_number' => [
                'format' => 'PO.?', // autonumber format. '?' will be replaced with the generated number.
                'length' => 5 // The number of digits in an autonumber
            ]
        ];
    }

}
```

You can also pass a `closure` for the format value.

```
public function getAutoNumberOptions()
{
    return [
        'order_number' => [
            'format' => function () {
                return 'PO/' . date('Ymd') . '/?'; // autonumber format. '?' will be replaced with the generated number.
            },
            'length' => 5 // The number of digits in the autonumber
        ]
    ];
}
```

Saving Model
------------

[](#saving-model)

```
$order = Order::create([
    'customer' => 'Mr. PO',
]);
```

The order\_number will be automatically generated based on the format given when saving the Order model.

```
echo $order->order_number;

// PO/20170803/00001
```

License
-------

[](#license)

Laravel-autonumber is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).

Contributing
------------

[](#contributing)

Please report any issue you find in the issues page. Pull requests are more than welcome.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~190 days

Recently: every ~238 days

Total

6

Last Release

729d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/09d53ad25482925c4828af650805d02bddb8b7c4f9c7b0f1f0e8a3d88c9a95e5?d=identicon)[virusphp](/maintainers/virusphp)

---

Top Contributors

[![virusphp](https://avatars.githubusercontent.com/u/17744762?v=4)](https://github.com/virusphp "virusphp (8 commits)")[![nexterid](https://avatars.githubusercontent.com/u/16434174?v=4)](https://github.com/nexterid "nexterid (1 commits)")

---

Tags

laraveleloquent autonumber

### Embed Badge

![Health badge](/badges/virusphp-autonumbering/health.svg)

```
[![Health](https://phpackages.com/badges/virusphp-autonumbering/health.svg)](https://phpackages.com/packages/virusphp-autonumbering)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.4M96](/packages/mongodb-laravel-mongodb)[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

1.6k32.6M46](/packages/kirschbaum-development-eloquent-power-joins)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8793.2M25](/packages/yajra-laravel-oci8)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k90.5k1](/packages/mike-bronner-laravel-model-caching)[glushkovds/phpclickhouse-laravel

Adapter of the most popular library https://github.com/smi2/phpClickHouse to Laravel

2051.5M2](/packages/glushkovds-phpclickhouse-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
