PHPackages                             raihan71/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. raihan71/laravel-autonumber

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

raihan71/laravel-autonumber
===========================

Laravel package to create an autonumber for Eloquent model

02PHP

Since Dec 20Pushed 4mo agoCompare

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

READMEChangelogDependenciesVersions (2)Used By (0)

```
# Laravel AutoNumber

[![Latest Stable Version](https://poser.pugx.org/alfa6661/laravel-autonumber/v/stable)](https://packagist.org/packages/alfa6661/laravel-autonumber)
[![Total Downloads](https://poser.pugx.org/alfa6661/laravel-autonumber/downloads)](https://packagist.org/packages/alfa6661/laravel-autonumber)
[![StyleCI](https://styleci.io/repos/99206904/shield)](https://styleci.io/repos/99206904)
[![License](https://poser.pugx.org/alfa6661/laravel-autonumber/license)](https://packagist.org/packages/alfa6661/laravel-autonumber)

Laravel package to create autonumber for Eloquent model

# Installation

You can install the package via composer:
```

composer require alfa6661/laravel-autonumber

```

Register the ServiceProvider in `config/app.php`

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

```

Publish the default configuration

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

```

Running migration

```
php artisan migrate

```

Usage
=====

[](#usage)

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

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

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

19

—

LowBetter than 10% of packages

Maintenance51

Moderate activity, may be stable

Popularity2

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity14

Early-stage or recently created project

 Bus Factor1

Top contributor holds 76.7% 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/eb6d1a39c02053ba28f216a4df362ea702f1905751e09b2bc722dec41cedf63e?d=identicon)[raihan71](/maintainers/raihan71)

---

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)")[![raihan71](https://avatars.githubusercontent.com/u/31585789?v=4)](https://github.com/raihan71 "raihan71 (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)")

### Embed Badge

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

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

###  Alternatives

[jacobbennett/sendyphp

A PHP Library for interfacing with the Sendy newsletter system (http://sendy.co)

134162.6k1](/packages/jacobbennett-sendyphp)[khill/fontawesomephp

PHP wrapper library for the fantastic Font Awesome icon set.

4676.3k4](/packages/khill-fontawesomephp)[smithfield-studio/acf-svg-icon-picker

Add ACF field for selecting SVG icons.

3710.8k](/packages/smithfield-studio-acf-svg-icon-picker)[marqu3s/yii2-behaviors

Collection of Yii2 behaviors

1211.6k](/packages/marqu3s-yii2-behaviors)

PHPackages © 2026

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