PHPackages                             soap/laravel-running-numbers - 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. soap/laravel-running-numbers

ActiveLibrary

soap/laravel-running-numbers
============================

This is my package laravel-running-numbers

v1.0.0(8mo ago)22.3k↓100%[1 PRs](https://github.com/soap/laravel-running-numbers/pulls)MITPHPPHP ^8.2CI passing

Since Apr 25Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/soap/laravel-running-numbers)[ Packagist](https://packagist.org/packages/soap/laravel-running-numbers)[ Docs](https://github.com/soap/laravel-running-numbers)[ GitHub Sponsors]()[ RSS](/packages/soap-laravel-running-numbers/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (9)Dependencies (13)Versions (13)Used By (0)

Maintain document running number for Laravel application
========================================================

[](#maintain-document-running-number-for-laravel-application)

[![Latest Version on Packagist](https://camo.githubusercontent.com/405d6623da247a50b8b494fd3a656f21771908b4faa575ed3226c761b4a9c08b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736f61702f6c61726176656c2d72756e6e696e672d6e756d626572732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/soap/laravel-running-numbers)[![PHPStan](https://github.com/soap/laravel-running-numbers/actions/workflows/phpstan.yml/badge.svg)](https://github.com/soap/laravel-running-numbers/actions/workflows/phpstan.yml)[![GitHub Tests Action Status](https://camo.githubusercontent.com/40ecaf49a4ded9daf90d70eeba7df864e8bed56e72cd72b4c848528c04f28430/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f736f61702f6c61726176656c2d72756e6e696e672d6e756d626572732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/soap/laravel-running-numbers/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/e6850b741f3a35674a28a8be271770da1ba9a68416f7c74526036c90aaca0e0d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f736f61702f6c61726176656c2d72756e6e696e672d6e756d626572732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/soap/laravel-running-numbers/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/37124349df435d421243331e67876d3d3c0b1012eaef8fe7fc44665983fe6cb6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736f61702f6c61726176656c2d72756e6e696e672d6e756d626572732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/soap/laravel-running-numbers)

The package provides a class to generate running number, keep track of them in database table. One running number type can have many prefix to generate running number. Generated running numbers was not stored in database, just keep last number for each prefix. You can reset it to specified value for each prefix. If specified type and prefix does not exists in the database, it will be create and assign number to 1.

Support us
----------

[](#support-us)

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://mycoding.academy/about-us). We publish all received postcards on [our virtual postcard wall](https://mycoding.academy/open-source/postcards).

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require soap/laravel-running-numbers
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="running-numbers-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="running-numbers-config"
```

This is the contents of the published config file:

```
return [
    'table_prefix' => '',
];
```

Usage
-----

[](#usage)

Using RunningNumber class to generate running number is deprecated. Now I introduced RunningNumberGenerator class instead.

### This is for version less than 0.0.6.

[](#this-is-for-version-less-than-006)

```
RunningNumber::generate('STUDENT_CODE', '672', 3);
// 673001
RunningNumber::generate('STUDENT_CODE', '672', 3);
// 673002

// Reset specified type and prefix to some value
RunningNumber::reset('STUDENT_CODE', '672', 0);

RunningNumber::generate('STUDENT_CODE', '672', 3);
// 673001

RunningNumber::delete('STUDENT_CODE', '672');
```

This is from my implementation.

```
namespace App\Observers;

use App\Models\Student;
use App\Models\EducationLevel;
use Soap\Laravel\RunningNumbers\RunningNumber;

class StudentObserver
{
    /**
     * Handle the Student "creating" event.
     *
     * @return void
     */
    public function creating(Student $student)
    {
        if (empty($student->student_code)) {
            $level = EducationLevel::find($student->education_level_id)->level;
            $prefix = ($student->registered_at->year + 543) % 100 . $level;
            $student->student_code = RunningNumber::generate('STUDENT_CODE', $prefix, 3);
        }
    }
}
```

### For verison 0.0.6 and above;

[](#for-verison-006-and-above)

#### Using RunningNumberGenerator to generate and reset value.

[](#using-runningnumbergenerator-to-generate-and-reset-value)

```
  RunningNumberGenerator::make()
     ->type('STUDENT_CODE')->prefix("672")->generate();

```

If type was not provided, 'Default' will be used. If prefix was not provided, date("Y") will be used.

### Set Running number format

[](#set-running-number-format)

Availabe token are {TYPE}, {PREFIX}, {NUMBER}. These information will be keep tracked in database record.

```
    RunningNumberGenerator::make()
     ->type('STUDENT_CODE')->prefix("672")->format("{PREFIX}-{NUMBER}")->generate();

```

### Reset running number to specified value.

[](#reset-running-number-to-specified-value)

Zero value if no value passed. Call generate(), running number will be increased by one and saved to database.

```
   RunningNumberGenerator::make()
     ->type('STUDENT_CODE')->prefix("672")->->format("{PREFIX}-{NUMBER}")->reset()->generate();
   // return 672-001
   RunningNumberGenerator::make()
     ->type('STUDENT_CODE')->prefix("672")->->format("{PREFIX}-{NUMBER}")->reset(1)->generate();
   // return 672-002

```

### Set length of padding number.

[](#set-length-of-padding-number)

If not set length of 3 will be used.

```
   RunningNumberGenerator::make()
     ->type('STUDENT_CODE')->prefix("672")->->format("{PREFIX}-{NUMBER}")->length(4)->reset()->generate();
   // return 672-0001

```

Artisan Command
---------------

[](#artisan-command)

### List

[](#list)

```
Usage:
  runningnumber:list [ []]

Arguments:
  type                  Type of running number
  prefix                Prefix before running number
```

### Generate

[](#generate)

```
Usage:
  runningnumber:generate [options] [--]

Arguments:
  type                             Type of running number
  prefix                           Prefix before running number
```

### Reset

[](#reset)

```
Usage:
  runningnumber:reset [options] [--]

Arguments:
  type                  Type of running number
  prefix                Prefix before running number

Options:
      --value[=VALUE]   Value to reset running number to [default: "1"]
```

### Delele

[](#delele)

```
Usage:
  runningnumber:delete

Arguments:
  type                  Type of running number
  prefix                Prefix before running number
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Prasit Gebsaap](https://github.com/soap)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance76

Regular maintenance activity

Popularity25

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 67.5% 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 ~62 days

Recently: every ~123 days

Total

9

Last Release

253d ago

Major Versions

v0.1.0 → v1.0.02025-09-02

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1073690?v=4)[Prasit Gebsaap](/maintainers/soap)[@soap](https://github.com/soap)

---

Top Contributors

[![soap](https://avatars.githubusercontent.com/u/1073690?v=4)](https://github.com/soap "soap (54 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (12 commits)")[![kpscyber](https://avatars.githubusercontent.com/u/126277570?v=4)](https://github.com/kpscyber "kpscyber (8 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (6 commits)")

---

Tags

laravelprasit gebsaaplaravel-running-numbers

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/soap-laravel-running-numbers/health.svg)

```
[![Health](https://phpackages.com/badges/soap-laravel-running-numbers/health.svg)](https://phpackages.com/packages/soap-laravel-running-numbers)
```

###  Alternatives

[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[spatie/laravel-prometheus

Export Laravel metrics to Prometheus

2651.3M6](/packages/spatie-laravel-prometheus)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)[scalar/laravel

Render your OpenAPI-based API reference

6183.9k2](/packages/scalar-laravel)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[musahmusah/laravel-multipayment-gateways

A Laravel Package that makes implementation of multiple payment Gateways endpoints and webhooks seamless

852.2k1](/packages/musahmusah-laravel-multipayment-gateways)

PHPackages © 2026

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