PHPackages                             vnot01/mylara-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. vnot01/mylara-autonumber

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

vnot01/mylara-autonumber
========================

Laravel package to create autonumber for Eloquent model

00PHP

Since Aug 20Pushed 2y ago1 watchersCompare

[ Source](https://github.com/vnot01/mylara-autonumber)[ Packagist](https://packagist.org/packages/vnot01/mylara-autonumber)[ RSS](/packages/vnot01-mylara-autonumber/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

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

[](#laravel-autonumber)

[![Latest Stable Version](https://camo.githubusercontent.com/0a015b5ae28e3e047766954bacb6f5c95a70445987c50ec9dbff15f12c209e08/68747470733a2f2f706f7365722e707567782e6f72672f766e6f7430312f6d796c6172612d6175746f6e756d6265722f762f737461626c65)](https://packagist.org/packages/vnot01/mylara-autonumber)[![Total Downloads](https://camo.githubusercontent.com/c7eb8cf22d8382af0af6a4006c0dc2ca069889a2c176260ba52b74503f925e80/68747470733a2f2f706f7365722e707567782e6f72672f766e6f7430312f6d796c6172612d6175746f6e756d6265722f646f776e6c6f616473)](https://packagist.org/packages/vnot01/mylara-autonumber)[![StyleCI](https://camo.githubusercontent.com/09134fdfcea3f6e8855780960031c93f748d14abc7542e1e222d72892604bd9b/68747470733a2f2f7374796c6563692e696f2f7265706f732f39393230363930342f736869656c64)](https://styleci.io/repos/680790804)[![License](https://camo.githubusercontent.com/ca583ef789acb0023cb97cccf09409845413bf63f11e87e12b8887a015f12b78/68747470733a2f2f706f7365722e707567782e6f72672f766e6f7430312f6d796c6172612d6175746f6e756d6265722f6c6963656e7365)](https://packagist.org/packages/vnot01/mylara-autonumber)

Laravel package to create autonumber for Eloquent model

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

[](#installation)

You can install the package via composer:

```
composer require vnot01/mylara-autonumber

```

Register the ServiceProvider in `config/app.php`

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

Publish the default configuration

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

```

Running migration

```
php artisan migrate

```

Usage
=====

[](#usage)

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

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

```
use MyLara\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

12

—

LowBetter than 0% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity21

Early-stage or recently created project

 Bus Factor1

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

### Community

Maintainers

![](https://www.gravatar.com/avatar/1178369b876ed0662f2f9e1f50ed06519b2ed2539b7c784d627a3fcdc5dc33e9?d=identicon)[vnot01](/maintainers/vnot01)

---

Top Contributors

[![vnot01](https://avatars.githubusercontent.com/u/56180550?v=4)](https://github.com/vnot01 "vnot01 (6 commits)")

### Embed Badge

![Health badge](/badges/vnot01-mylara-autonumber/health.svg)

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

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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