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

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

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

This is my package laravel-running-numbers

v1.1.0(1mo ago)23.7k[2 PRs](https://github.com/soap/laravel-running-numbers/pulls)MITPHPPHP ^8.3CI passing

Since Apr 25Pushed 2w 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 3d ago

READMEChangelog (10)Dependencies (26)Versions (18)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

52

—

FairBetter than 96% of packages

Maintenance94

Actively maintained with recent releases

Popularity25

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 61% 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 ~84 days

Recently: every ~156 days

Total

10

Last Release

45d ago

Major Versions

v0.1.0 → v1.0.02025-09-02

PHP version history (2 changes)v0.0.1PHP ^8.2

v1.1.0PHP ^8.3

### 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 (61 commits)")[![kpscyber](https://avatars.githubusercontent.com/u/126277570?v=4)](https://github.com/kpscyber "kpscyber (19 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (14 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

[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

329530.5k29](/packages/codewithdennis-filament-select-tree)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

124603.0k](/packages/worksome-exchange)[tarfin-labs/event-machine

Event-driven state machines for Laravel with event sourcing, type-safe context, and full audit trail.

199.4k](/packages/tarfin-labs-event-machine)

PHPackages © 2026

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