PHPackages                             saade/laravel-uuid - 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. [Database &amp; ORM](/categories/database)
4. /
5. saade/laravel-uuid

ActiveLibrary[Database &amp; ORM](/categories/database)

saade/laravel-uuid
==================

A small package for adding UUIDs to Eloquent models.

v2.0.1(1y ago)06.0k↓80.8%MITPHPPHP ^8.0CI passing

Since Feb 28Pushed 1y agoCompare

[ Source](https://github.com/saade/laravel-uuid)[ Packagist](https://packagist.org/packages/saade/laravel-uuid)[ Docs](https://github.com/saade/laravel-uuid)[ GitHub Sponsors](https://github.com/saade)[ RSS](/packages/saade-laravel-uuid/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (1)Dependencies (7)Versions (2)Used By (0)

A small package for adding UUIDs to Eloquent models.
====================================================

[](#a-small-package-for-adding-uuids-to-eloquent-models)

[![Latest Version on Packagist](https://camo.githubusercontent.com/22705860c3b9384bef2368660b76c13ae5ef5377b5479062ffd576690853a3ec/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73616164652f6c61726176656c2d757569642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/saade/laravel-uuid)[![GitHub Tests Action Status](https://camo.githubusercontent.com/e56c51e12fc27dd428722f0ec22d81afda4990723f8a06464f31daabfe133a5a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f73616164652f6c61726176656c2d757569642f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/saade/laravel-uuid/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/9405bec5eb3122278eff5ad175d8543ecd04dcf37ac5015f50954396a2b2f09c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f73616164652f6c61726176656c2d757569642f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://github.com/saade/laravel-uuid/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/1d5be1a0d41a2df428cbb13aeed036fafd63fbe1dfb1dd11189bb0609bbb99f9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73616164652f6c61726176656c2d757569642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/saade/laravel-uuid)

Caution

This package is a fork of [saade/laravel-uuid](https://packagist.org/packages/saade/laravel-uuid) (which is no longer maintained) to keep old projects still alive.

Laravel now has [first-party support for generating UUIDs and ULIDs](https://laravel.com/docs/eloquent#uuid-and-ulid-keys) on Eloquent models, you should use that instead.

This package will not receive any new features or updates, only compatibility fixes.

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

[](#installation)

You can install the package via composer:

```
composer require saade/laravel-uuid
```

Usage
-----

[](#usage)

There are 2 methods for applying automatic UUID generation to your models:

### 1. Applying a trait

[](#1-applying-a-trait)

Add the `Saade\Uuid\Concerns\HasUuid` trait to your model:

```
class Post extends Model
{
    use \Saade\Uuid\Concerns\HasUuid;
}
```

This will automatically assign a time-ordered UUID to the `uuid` column on your model. UUIDs are generated using the `Str::orderedUuid()` method provided by Laravel.

If you wish to change the column that is used, you can define a `uuidColumn` method on your model:

```
class Post extends Model
{
    use \Saade\Uuid\Concerns\HasUuid;

    public function uuidColumn(): string
    {
        return 'guid';
    }
}
```

#### `findByUuid` &amp; `findByUuidOrFail`

[](#findbyuuid--findbyuuidorfail)

You can use the `Model::findByUuid` and `Model::findByUuidOrFail` methods to quickly retrieve a model from it's UUID. These behave the same way as `Model::find` and `Model::findOrFail`.

### 2. Mass-registration in `ServiceProvider`

[](#2-mass-registration-in-serviceprovider)

If you want to use the defaults and would like to avoid adding more traits to your model, you can mass-register your models in the `boot` method of a `ServiceProvider`.

```
use Saade\Uuid\Uuid;

class AppServiceProvider extends ServiceProvider
{
    public function boot()
    {
        Uuid::generateFor([
            \App\Models\Post::class,
        ]);
    }
}
```

### Using the UUID in route definitions

[](#using-the-uuid-in-route-definitions)

If you want to use your `uuid` column as the default route-model binding column, you can implement the `Saade\Uuid\Contracts\WithUuidRouteKey` contract on your model.

This will force the `HasUuid` trait to use the `uuid` column as the return value of `getRouteKeyName` which Laravel uses to determine how to receive a model for implicit route-model binding.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

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

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

[](#security-vulnerabilities)

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

Credits
-------

[](#credits)

- [Ryan Chandler](https://github.com/ryangjchandler) - Original author
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance41

Moderate activity, may be stable

Popularity23

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 79.4% 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

Unknown

Total

1

Last Release

490d ago

### Community

Maintainers

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

---

Top Contributors

[![ryangjchandler](https://avatars.githubusercontent.com/u/41837763?v=4)](https://github.com/ryangjchandler "ryangjchandler (27 commits)")[![edgrosvenor](https://avatars.githubusercontent.com/u/1053395?v=4)](https://github.com/edgrosvenor "edgrosvenor (4 commits)")[![saade](https://avatars.githubusercontent.com/u/14329460?v=4)](https://github.com/saade "saade (3 commits)")

---

Tags

laravelsaadelaravel-uuid

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/saade-laravel-uuid/health.svg)

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

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k102.4M1.4k](/packages/spatie-laravel-permission)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k11.2M100](/packages/dedoc-scramble)[wnx/laravel-backup-restore

A package to restore database backups made with spatie/laravel-backup.

213420.1k2](/packages/wnx-laravel-backup-restore)[spatie/laravel-passkeys

Use passkeys in your Laravel app

471890.7k39](/packages/spatie-laravel-passkeys)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

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

PHPackages © 2026

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