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

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

gid-m/laravel-autonumber
========================

Laravel package to create autonumber for Eloquent model

v1.0.0(4y ago)291MITPHP

Since Apr 14Pushed 4y agoCompare

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

READMEChangelogDependencies (3)Versions (2)Used By (0)

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

[](#laravel-autonumber)

[![Latest Stable Version](https://camo.githubusercontent.com/6b4ed7fc62ea2bfc8189777c448b8d25d476a1cb7ca456bc6be7311c60619ce6/68747470733a2f2f706f7365722e707567782e6f72672f6769642f6c61726176656c2d6175746f6e756d6265722f762f737461626c65)](https://packagist.org/packages/gid/laravel-autonumber)[![Total Downloads](https://camo.githubusercontent.com/207da46e6e8d4a7ce6e9128be453a0475f1f6d86100b4e8616aa00e60bbdd34b/68747470733a2f2f706f7365722e707567782e6f72672f6769642f6c61726176656c2d6175746f6e756d6265722f646f776e6c6f616473)](https://packagist.org/packages/gid/laravel-autonumber)[![StyleCI](https://camo.githubusercontent.com/09134fdfcea3f6e8855780960031c93f748d14abc7542e1e222d72892604bd9b/68747470733a2f2f7374796c6563692e696f2f7265706f732f39393230363930342f736869656c64)](https://styleci.io/repos/99206904)[![License](https://camo.githubusercontent.com/f6b076f2e907d1b0d8d963f03c6c516f2842661288f90872245a64e3dcd050b2/68747470733a2f2f706f7365722e707567782e6f72672f6769642f6c61726176656c2d6175746f6e756d6265722f6c6963656e7365)](https://packagist.org/packages/gid/laravel-autonumber)

Laravel package to create autonumber for Eloquent model

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

[](#installation)

You can install the package via composer:

```
composer require gid/laravel-autonumber

```

Register the ServiceProvider in `config/app.php`

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

Publish the default configuration

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

```

Running migration

```
php artisan migrate

```

Usage
=====

[](#usage)

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

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

```
use Gid\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' => '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

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 84.6% 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

Unknown

Total

1

Last Release

1540d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/88541252?v=4)[gid-m](/maintainers/gid-m)[@gid-m](https://github.com/gid-m)

---

Top Contributors

[![alfa6661](https://avatars.githubusercontent.com/u/3650559?v=4)](https://github.com/alfa6661 "alfa6661 (22 commits)")[![dea96](https://avatars.githubusercontent.com/u/32514477?v=4)](https://github.com/dea96 "dea96 (1 commits)")[![gid-m](https://avatars.githubusercontent.com/u/88541252?v=4)](https://github.com/gid-m "gid-m (1 commits)")[![wuwx](https://avatars.githubusercontent.com/u/4401?v=4)](https://github.com/wuwx "wuwx (1 commits)")[![yudifaturohman](https://avatars.githubusercontent.com/u/50742212?v=4)](https://github.com/yudifaturohman "yudifaturohman (1 commits)")

---

Tags

laraveleloquent autonumber

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/gid-m-laravel-autonumber/health.svg)](https://phpackages.com/packages/gid-m-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.4M94](/packages/mongodb-laravel-mongodb)[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

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

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M129](/packages/laravel-pulse)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8793.2M25](/packages/yajra-laravel-oci8)[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)
