PHPackages                             muktar-sayedsaleh/laravel-custom-ids-generator - 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. muktar-sayedsaleh/laravel-custom-ids-generator

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

muktar-sayedsaleh/laravel-custom-ids-generator
==============================================

A PHP package for Laravel developers which allows them to generate custom-format IDs for any model.

048PHP

Since Jun 22Pushed 2y ago1 watchersCompare

[ Source](https://github.com/MukhtarSayedSaleh/laravel-custom-ids-generator)[ Packagist](https://packagist.org/packages/muktar-sayedsaleh/laravel-custom-ids-generator)[ RSS](/packages/muktar-sayedsaleh-laravel-custom-ids-generator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

A PHP package for Laravel developers which allows them to generate custom-format IDs for any model.

How to install?
---------------

[](#how-to-install)

```
composer require muktar-sayedsaleh/laravel-custom-ids-generator

```

How to use?
-----------

[](#how-to-use)

```
use MuktarSayedSaleh\LaravelCustomIds\IdsGenerator;
use App\Models\User;

$generator = new IdsGenerator();
$id = $generator->next(
    $model=User::class
);

// $id will be 000001
// Use the generated ID ($id) however you want.
```

### IdsGenerator Parameters:

[](#idsgenerator-parameters)

1. $model: The laravel model class (Required).
2. $prefix: The desired prefix if any (Optional, default value: '').
3. $suffix: The desired suffix if any (Optional, default value: '').
4. $sequence\_length: The desired length of the sequence number (Optional, default value: 6).
5. $format: The desired format of the generated ID (Optional, default value: '{prefix}{sequence}{suffix}'). Accepted placeholders are:
    - `{prefix}` the prefix
    - `{suffix}` the suffix
    - `{sequence}` the sequence number
    - `{Y}` The year in YYYY format
    - `{y}` The year in YY format
    - `{F}` The month in January through December format
    - `{M}` A short textual representation of a month, three letters: Jan through Dec
    - `{m}` Numeric representation of a month, with leading zeros: 01 through 12
    - `{n}` Numeric representation of a month, without leading zeros: 1 through 12
    - `{l}` A textual representation of a day, three letters: Sunday through Saturday
    - `{D}` A textual representation of a day, three letters: Mon through Sun
    - `{d}` Day of the month, 2 digits with leading zeros: 01 to 31
    - `{j}` Day of the month without leading zeros: 1 to 31
    - `anyothertext` Will be rendered as is
6. $unique\_field\_name: A field of the $model model, which the function will compare against to make sure that the generated ID is not used before.

### Advace Examples:

[](#advace-examples)

#### Custom prefix:

[](#custom-prefix)

```
use MuktarSayedSaleh\LaravelCustomIds\IdsGenerator;
use App\Models\User;

$generator = new IdsGenerator();
$id = $generator->next(
    model: User::class,
    prefix: 'Monjz'
);

// $id will be Monjz000001
// Use the generated ID ($id) however you want.
```

#### Custom suffix:

[](#custom-suffix)

```
use MuktarSayedSaleh\LaravelCustomIds\IdsGenerator;
use App\Models\User;

$generator = new IdsGenerator();
$id = $generator->next(
    model: User::class,
    suffix: 'Monjz'
);

// $id will be 000001Monjz
// Use the generated ID ($id) however you want.
```

#### Custom prefix &amp; suffix:

[](#custom-prefix--suffix)

```
use MuktarSayedSaleh\LaravelCustomIds\IdsGenerator;
use App\Models\User;

$generator = new IdsGenerator();
$id = $generator->next(
    model: User::class,
    prefix: 'Monjz',
    suffix: 'Monjz'
);

// $id will be Monjz000001Monjz
// Use the generated ID ($id) however you want.
```

#### Custom length:

[](#custom-length)

```
use MuktarSayedSaleh\LaravelCustomIds\IdsGenerator;
use App\Models\User;

$generator = new IdsGenerator();
$id = $generator->next(
    model: User::class,
    sequence_length: 12
);

// $id will be 000000000001
// Use the generated ID ($id) however you want.
```

#### Custom format:

[](#custom-format)

```
use MuktarSayedSaleh\LaravelCustomIds\IdsGenerator;
use App\Models\User;

$generator = new IdsGenerator();
$id = $generator->next(
    model: User::class,
    format: 'RFQS-{sequence}-2022'
);

// $id will be RFQS-000001-2022
// Use the generated ID ($id) however you want.
```

#### Custom format - advance:

[](#custom-format---advance)

```
use MuktarSayedSaleh\LaravelCustomIds\IdsGenerator;
use App\Models\User;

$generator = new IdsGenerator();
$id = $generator->next(
    model: User::class,
    format: 'RFQS-{Y}-{M}-{n}-{l}-{sequence}'
);

// $id will be RFQS-2022-Feb-2-Wednesday-000001
// Use the generated ID ($id) however you want.
```

#### With uniquness check:

[](#with-uniquness-check)

```
use MuktarSayedSaleh\LaravelCustomIds\IdsGenerator;
use App\Models\User;

$generator = new IdsGenerator();
$id = $generator->next(
    model: User::class,
    format: 'RFQS-{Y}-{M}-{n}-{l}-{sequence}',
    unique_field_name: 'reference_number'
);

// $id will be RFQS-2022-Feb-2-Wednesday-000001
// Use the generated ID ($id) however you want.
```

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity22

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/71e1f0fcfe4092358f9f6d14a5a9141b46cfe899f3dbb55b8382d2a506fe7269?d=identicon)[MukhtarSayedSaleh](/maintainers/MukhtarSayedSaleh)

---

Top Contributors

[![muktarsayedsaleh](https://avatars.githubusercontent.com/u/10845598?v=4)](https://github.com/muktarsayedsaleh "muktarsayedsaleh (3 commits)")

### Embed Badge

![Health badge](/badges/muktar-sayedsaleh-laravel-custom-ids-generator/health.svg)

```
[![Health](https://phpackages.com/badges/muktar-sayedsaleh-laravel-custom-ids-generator/health.svg)](https://phpackages.com/packages/muktar-sayedsaleh-laravel-custom-ids-generator)
```

###  Alternatives

[vildanbina/laravel-versions

A Laravel package for managing model drafts.

333.3k](/packages/vildanbina-laravel-versions)

PHPackages © 2026

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