PHPackages                             alecgarcia/laravel-uid - 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. alecgarcia/laravel-uid

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

alecgarcia/laravel-uid
======================

Create UIDs like the ones Stripe generates. These can be used on your models or on their own.

v1.0.0(4y ago)19[1 issues](https://github.com/alecgarcia/laravel-uid/issues)MITPHP

Since Jan 24Pushed 2y ago1 watchersCompare

[ Source](https://github.com/alecgarcia/laravel-uid)[ Packagist](https://packagist.org/packages/alecgarcia/laravel-uid)[ Docs](https://github.com/alecgarcia/laravel-uid)[ RSS](/packages/alecgarcia-laravel-uid/feed)WikiDiscussions main Synced today

READMEChangelog (3)Dependencies (3)Versions (4)Used By (0)

LaravelUid
==========

[](#laraveluid)

[![Latest Stable Version](https://camo.githubusercontent.com/cf882ec7fed0eddb0d429a6f767a26088f6462a7a0166319cb0f9f0f49a5dd4b/687474703a2f2f706f7365722e707567782e6f72672f616c65636761726369612f6c61726176656c2d7569642f76)](https://packagist.org/packages/alecgarcia/laravel-uid)[![Total Downloads](https://camo.githubusercontent.com/6db16d4e2956f17680c6c9a6e2c306888c6f3202f79b9f5649ba5d2b6ff5830f/687474703a2f2f706f7365722e707567782e6f72672f616c65636761726369612f6c61726176656c2d7569642f646f776e6c6f616473)](https://packagist.org/packages/alecgarcia/laravel-uid)[![License](https://camo.githubusercontent.com/1a6395d19036fa744b10c5ca994ef521a1c315ae11b6928a7cd45ae2e16a8006/687474703a2f2f706f7365722e707567782e6f72672f616c65636761726369612f6c61726176656c2d7569642f6c6963656e7365)](https://packagist.org/packages/alecgarcia/laravel-uid)[![Dependents](https://camo.githubusercontent.com/1431b3434eb9c368aef72d677d335a7b2681b4f6d3f66ee80197f9eb2ced13b6/687474703a2f2f706f7365722e707567782e6f72672f616c65636761726369612f6c61726176656c2d7569642f646570656e64656e7473)](https://packagist.org/packages/alecgarcia/laravel-uid)

This package creates UIDs like the ones Stripe uses for your models or on their own.

Installation
============

[](#installation)

#### Via Composer

[](#via-composer)

```
$ composer require alecgarcia/laravel-uid
```

Usage
=====

[](#usage)

To use with a model
-------------------

[](#to-use-with-a-model)

### 1. Add uid column to table

[](#1-add-uid-column-to-table)

#### With an existing Model

[](#with-an-existing-model)

1. Add a migration

```
php artisan make:migration --table users add-uid-to-users
```

2. Open up the migration file you just created and add a `uid` field.
    1. If you overrode the column name in either the config for the default or in your model, make sure you create the column in your table to match.

```
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->string('uid', 32)->after('id')->unique();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->dropColumn('uid');
        });
    }
```

#### With a new Model

[](#with-a-new-model)

1. Open up the migration file for the model and add a `uid` field
    1. If you overrode the column name in either the config for the default or in your model, make sure you create the column in your table to match.

```
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('uid', 32)->unique();
            $table->timestamps();
        });
    }
```

### 2. Add the trait to your model

[](#2-add-the-trait-to-your-model)

```
 "uid_nuv8V6GH"     // Can set the prefix that is used and the length
```

Customization
=============

[](#customization)

### Using the trait

[](#using-the-trait)

You can add the following properties to your model to configure the Uid trait.

- This will override the defaults as well as the config file.

```
 '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
    'prefix_separator' => '_',
    'uid_column' => 'uid',
    'length' => 16,
    'check' => true,
];
```

Change log
==========

[](#change-log)

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

Testing
=======

[](#testing)

```
$ php vendor/bin/phpunit
```

Contributing
============

[](#contributing)

Please see [contributing.md](contributing.md) for details and a todolist.

Security
========

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
=======

[](#credits)

- [Alec Garcia](https://github.com/alecgarcia)
- [All Contributors](https://github.com/alecgarcia/laravel-uid/graphs/contributors)
- Originally influenced by [dpods/laravel-uid](https://github.com/dpods/laravel-uid)

License
=======

[](#license)

MIT. Please see the [license file](LICENSE) for more information.

###  Health Score

18

↓

LowBetter than 8% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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 ~3 days

Total

3

Last Release

1615d ago

Major Versions

v0.2.0 → v1.0.02022-01-30

### Community

Maintainers

![](https://www.gravatar.com/avatar/8f50e7db4f286d0bb0f14556f8a028a1c37ab5078c1601abd25f733280fcc612?d=identicon)[alecgarcia](/maintainers/alecgarcia)

---

Top Contributors

[![alecgarcia](https://avatars.githubusercontent.com/u/14018933?v=4)](https://github.com/alecgarcia "alecgarcia (37 commits)")

---

Tags

laravellaravel-packagepackagelaravelUIDLaravelUid

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/alecgarcia-laravel-uid/health.svg)

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

###  Alternatives

[stephenjude/filament-blog

Filament Blog Builder

20619.4k](/packages/stephenjude-filament-blog)[datomatic/nova-detached-actions

A Laravel Nova tool to allow for placing actions in the Nova toolbar detached from the checkbox selection mechanism.

11273.0k](/packages/datomatic-nova-detached-actions)

PHPackages © 2026

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