PHPackages                             sayawrt/unik-id - 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. sayawrt/unik-id

ActiveLibrary

sayawrt/unik-id
===============

Cara terbaik membuat Id unik di Laravel

v2.0.1(1y ago)065cc-by-4.0PHPPHP ^7.4|^8.0

Since Jun 1Pushed 1y ago1 watchersCompare

[ Source](https://github.com/rifkitaufik/unik-id)[ Packagist](https://packagist.org/packages/sayawrt/unik-id)[ RSS](/packages/sayawrt-unik-id/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

[![Logo](https://camo.githubusercontent.com/c52b7170e0e2319677d0a3fe91ad8adb91c8f450ab037b465ae0570c21cd1c25/68747470733a2f2f692e6962622e636f2e636f6d2f4434386742544e2f736179617772742d756e696b2d69642e706e67)](https://camo.githubusercontent.com/c52b7170e0e2319677d0a3fe91ad8adb91c8f450ab037b465ae0570c21cd1c25/68747470733a2f2f692e6962622e636f2e636f6d2f4434386742544e2f736179617772742d756e696b2d69642e706e67)

SayaWRT - Unik ID
=================

[](#sayawrt---unik-id)

#### Mudah membuat unik id pada framework Laravel

[](#mudah-membuat-unik-id-pada-framework-laravel)

Pemasangan
----------

[](#pemasangan)

```
  composer require sayawrt/unik-id
```

Gimana Sih Cara Pakenya?
------------------------

[](#gimana-sih-cara-pakenya)

gunakan ini setiap akan digunakan

```
  use SayaWRT\Unik\IdGenerator;
```

```
  public function store(Request $request){

	$id = IdGenerator::generate(['table' => 'todos', 'length' => 6, 'prefix' => date('y')]);

	$todo = new Todo();
	$todo->id = $id;
	$todo->title = $request->get('title');
	$todo->save();

}
```

### Parameter

[](#parameter)

Kamu harus memberikan array asosiatif kedalam generate, yang berisi table, length, prefix

`table` table yang kamu gunakan

`field` kolom yang digunakan pada table / default 'id'

`length` panjang total karakter unik id

`prefix` kode prefix (bebas) yang mau kamu gunakan

`reset_on_prefix_change` default true, jika prefix berubah akan kembali ke angka 1

```
$config = [
    'table' => 'todos',
    'length' => 6,
    'prefix' => date('y')
];

// now use it
$id = IdGenerator::generate($config);
```

```
// use within single line code
$id = IdGenerator::generate(['table' => 'todos', 'length' => 6, 'prefix' => date('y')]);

// output: 160001
```

#### Contoh 2

[](#contoh-2)

```
$id = IdGenerator::generate(['table' => 'invoices', 'length' => 10, 'prefix' =>'INV-']);
//output: INV-000001
```

#### Contoh 3

[](#contoh-3)

```
$id = IdGenerator::generate(['table' => 'invoices', 'length' => 10, 'prefix' =>date('ym')]);
//output: 1910000001
```

#### Contoh 4

[](#contoh-4)

```
$id = IdGenerator::generate(['table' => 'products','field'=>'pid', 'length' => 6, 'prefix' =>date('P')]);
//output: P00001
```

#### Contoh 5

[](#contoh-5)

#### pada contoh dibawah ini menggunakan "reset\_on\_prefix\_change" bernilai TRUE

[](#pada-contoh-dibawah-ini-menggunakan-reset_on_prefix_change-bernilai-true)

### reset ID Tahunan

[](#reset-id-tahunan)

```
$id = IdGenerator::generate(['table' => 'invoices', 'length' => 10, 'prefix' =>date('y')]);
//output: 2000000001,2000000002,2000000003
//output: 2100000001,2100000002,2100000003
```

### reset ID Bulanan

[](#reset-id-bulanan)

```
$id = IdGenerator::generate(['table' => 'invoices', 'length' => 10, 'prefix' =>date('ym')]);
//output: 1912000001,1912000002,1912000003
//output: 2001000001,2001000002,2001000003
```

### atau perubahan apapun pada prefix

[](#atau-perubahan-apapun-pada-prefix)

```
$id = IdGenerator::generate(['table' => 'products', 'length' => 6, 'prefix' => $prefix]);
//output: A00001,A00002,B00001,B00002
```

Dukungan
--------

[](#dukungan)

Terimakasih atas dukungannya.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

709d ago

### Community

Maintainers

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

---

Top Contributors

[![rifkitaufik](https://avatars.githubusercontent.com/u/79295797?v=4)](https://github.com/rifkitaufik "rifkitaufik (13 commits)")

### Embed Badge

![Health badge](/badges/sayawrt-unik-id/health.svg)

```
[![Health](https://phpackages.com/badges/sayawrt-unik-id/health.svg)](https://phpackages.com/packages/sayawrt-unik-id)
```

PHPackages © 2026

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