PHPackages                             wuwx/laravel-autonumber - 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. wuwx/laravel-autonumber

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

wuwx/laravel-autonumber
=======================

Laravel package to create autonumber for Eloquent model

v5.0.0(2mo ago)12.7kMITPHPPHP ^7.0|^8.0CI failing

Since Aug 3Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/wuwx/laravel-autonumber)[ Packagist](https://packagist.org/packages/wuwx/laravel-autonumber)[ Docs](https://github.com/wuwx/laravel-autonumber)[ RSS](/packages/wuwx-laravel-autonumber/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (10)Versions (10)Used By (0)

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

[](#laravel-autonumber)

[![Latest Stable Version](https://camo.githubusercontent.com/80e078038f8bdacec23a9379384eed5790d4baab3ff10e102ad2a88337ff7c9e/68747470733a2f2f706f7365722e707567782e6f72672f777577782f6c61726176656c2d6175746f6e756d6265722f762f737461626c65)](https://packagist.org/packages/wuwx/laravel-autonumber)[![Total Downloads](https://camo.githubusercontent.com/da4793f199d861cb5df545d931a2e4c16d6e2091b680e42b4efbb10f053d2cee/68747470733a2f2f706f7365722e707567782e6f72672f777577782f6c61726176656c2d6175746f6e756d6265722f646f776e6c6f616473)](https://packagist.org/packages/wuwx/laravel-autonumber)[![StyleCI](https://camo.githubusercontent.com/09134fdfcea3f6e8855780960031c93f748d14abc7542e1e222d72892604bd9b/68747470733a2f2f7374796c6563692e696f2f7265706f732f39393230363930342f736869656c64)](https://styleci.io/repos/99206904)[![License](https://camo.githubusercontent.com/9711c8fcb7837cb317d84e17b03fa3944c3ab4d78f570046a70d1fe1ba8a8b91/68747470733a2f2f706f7365722e707567782e6f72672f777577782f6c61726176656c2d6175746f6e756d6265722f6c6963656e7365)](https://packagist.org/packages/wuwx/laravel-autonumber)

Laravel package to create autonumber for Eloquent model

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

[](#installation)

You can install the package via composer:

```
composer require wuwx/laravel-autonumber

```

Register the ServiceProvider in `config/app.php`

```
'providers' => [
    // ...
    Wuwx\LaravelAutoNumber\AutoNumberServiceProvider::class,
],
```

Publish the default configuration

```
php artisan vendor:publish --provider='Wuwx\LaravelAutoNumber\AutoNumberServiceProvider'

```

Running migration

```
php artisan migrate

```

Usage
=====

[](#usage)

Your Eloquent models should use the `Wuwx\LaravelAutoNumber\AutoNumberTrait` trait

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

```
use Wuwx\LaravelAutoNumber\AutoNumberTrait;

class Order extends Model
{
    use AutoNumberTrait;

    /**
     * Return the autonumber configuration array for this model.
     *
     * @return array
     */
    public function getAutoNumberOptions()
    {
        return [
            'order_number' => [
                'format' => 'SO.?', // 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 'SO/' . 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. X',
]);
```

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

```
echo $order->order_number;

// SO/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

51

—

FairBetter than 95% of packages

Maintenance83

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 58.1% 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 ~396 days

Recently: every ~677 days

Total

9

Last Release

88d ago

Major Versions

v1.3.0 → v2.0.02018-11-06

v2.0.0 → v3.0.02019-09-15

v3.1.1 → v4.0.02021-03-20

v4.0.0 → v5.0.02026-04-07

PHP version history (3 changes)1.0PHP &gt;=5.6.4 || ^7.0

v4.0.0PHP &gt;=5.6.4 || ^7.0 || ^8.0

v5.0.0PHP ^7.0|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/9c1977bba4586c70a4bdb6faaee4823184904ff3bd3246e79069871465500611?d=identicon)[wuwx](/maintainers/wuwx)

---

Top Contributors

[![wuwx](https://avatars.githubusercontent.com/u/4401?v=4)](https://github.com/wuwx "wuwx (18 commits)")[![alfa6661](https://avatars.githubusercontent.com/u/3650559?v=4)](https://github.com/alfa6661 "alfa6661 (13 commits)")

---

Tags

laraveleloquent autonumber

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/wuwx-laravel-autonumber/health.svg)

```
[![Health](https://phpackages.com/badges/wuwx-laravel-autonumber/health.svg)](https://phpackages.com/packages/wuwx-laravel-autonumber)
```

###  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)[api-platform/laravel

API Platform support for Laravel

58171.5k14](/packages/api-platform-laravel)[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.4k91.9k1](/packages/mike-bronner-laravel-model-caching)

PHPackages © 2026

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