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

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

alfa6661/laravel-autonumber
===========================

Laravel package to create autonumber for Eloquent model

1.2.5(3y ago)4715.9k↓33.3%23[2 PRs](https://github.com/alfa6661/laravel-autonumber/pulls)MITPHP

Since Aug 3Pushed 2y ago1 watchersCompare

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

READMEChangelog (8)Dependencies (3)Versions (9)Used By (0)

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

[](#laravel-autonumber)

[![Latest Stable Version](https://camo.githubusercontent.com/46b6dad23cfe159ea7014c6142d52d9f636858791a1ce4bf4136e4f5eb3aaef5/68747470733a2f2f706f7365722e707567782e6f72672f616c6661363636312f6c61726176656c2d6175746f6e756d6265722f762f737461626c65)](https://packagist.org/packages/alfa6661/laravel-autonumber)[![Total Downloads](https://camo.githubusercontent.com/67b3305404bd55361e4ab29f8c2d961c73f7da675935f4444f2924831ecfc88e/68747470733a2f2f706f7365722e707567782e6f72672f616c6661363636312f6c61726176656c2d6175746f6e756d6265722f646f776e6c6f616473)](https://packagist.org/packages/alfa6661/laravel-autonumber)[![StyleCI](https://camo.githubusercontent.com/09134fdfcea3f6e8855780960031c93f748d14abc7542e1e222d72892604bd9b/68747470733a2f2f7374796c6563692e696f2f7265706f732f39393230363930342f736869656c64)](https://styleci.io/repos/99206904)[![License](https://camo.githubusercontent.com/29799f6ea140d0ffc55f710a097ecc5baf6e201daec2fc70cc07aa281524e2dc/68747470733a2f2f706f7365722e707567782e6f72672f616c6661363636312f6c61726176656c2d6175746f6e756d6265722f6c6963656e7365)](https://packagist.org/packages/alfa6661/laravel-autonumber)

Laravel package to create autonumber for Eloquent model

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

[](#installation)

You can install the package via composer:

```
composer require alfa6661/laravel-autonumber

```

Register the ServiceProvider in `config/app.php`

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

Publish the default configuration

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

```

Running migration

```
php artisan migrate

```

Usage
=====

[](#usage)

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

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

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

39

—

LowBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 82.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 ~261 days

Recently: every ~336 days

Total

8

Last Release

1373d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ef0480adb6c2494f21910eb4e69ab92b02e075bfdad37c242fed4f20d0e5412c?d=identicon)[alfa6661](/maintainers/alfa6661)

---

Top Contributors

[![alfa6661](https://avatars.githubusercontent.com/u/3650559?v=4)](https://github.com/alfa6661 "alfa6661 (23 commits)")[![MarJose123](https://avatars.githubusercontent.com/u/18107626?v=4)](https://github.com/MarJose123 "MarJose123 (2 commits)")[![dea96](https://avatars.githubusercontent.com/u/32514477?v=4)](https://github.com/dea96 "dea96 (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

autonumbereloquenteloquent-modelslaravellaraveleloquent autonumber

### Embed Badge

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

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

###  Alternatives

[cviebrock/eloquent-sluggable

Easy creation of slugs for your Eloquent models in Laravel

4.0k13.6M253](/packages/cviebrock-eloquent-sluggable)[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[cviebrock/eloquent-taggable

Easy ability to tag your Eloquent models in Laravel.

567694.8k3](/packages/cviebrock-eloquent-taggable)[watson/validating

Eloquent model validating trait.

9723.3M47](/packages/watson-validating)[cybercog/laravel-love

Make Laravel Eloquent models reactable with any type of emotions in a minutes!

1.2k302.7k1](/packages/cybercog-laravel-love)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.2M13](/packages/reedware-laravel-relation-joins)

PHPackages © 2026

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