PHPackages                             astrotomic/laravel-eloquent-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. astrotomic/laravel-eloquent-uuid

Abandoned → [illuminate/database](/?search=illuminate%2Fdatabase)ArchivedLibrary[Database &amp; ORM](/categories/database)

astrotomic/laravel-eloquent-uuid
================================

A simple drop-in solution for UUID support in your Eloquent models.

1.5.0(4y ago)1325.2k51MITPHPPHP ^7.4 || ^8.0

Since Feb 15Pushed 4y ago1 watchersCompare

[ Source](https://github.com/Astrotomic/laravel-eloquent-uuid)[ Packagist](https://packagist.org/packages/astrotomic/laravel-eloquent-uuid)[ Docs](https://astrotomic.info)[ Fund](https://forest.astrotomic.info)[ GitHub Sponsors](https://github.com/Gummibeer)[ RSS](/packages/astrotomic-laravel-eloquent-uuid/feed)WikiDiscussions main Synced yesterday

READMEChangelog (7)Dependencies (5)Versions (8)Used By (1)

Laravel Eloquent UUID
=====================

[](#laravel-eloquent-uuid)

[![Latest Version](https://camo.githubusercontent.com/49e833b2b62ce3bfc2cd3bf6a2ced96e8c4667647d012897c44916f7f479f3dc/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f617374726f746f6d69632f6c61726176656c2d656c6f7175656e742d757569642e7376673f6c6162656c3d52656c65617365267374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/astrotomic/laravel-eloquent-uuid)[![MIT License](https://camo.githubusercontent.com/41496c90f5d335ea7645d8663552a12c9992b166d5dc33194e3291a2fa49eb8b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f417374726f746f6d69632f6c61726176656c2d656c6f7175656e742d757569642e7376673f6c6162656c3d4c6963656e736526636f6c6f723d626c7565267374796c653d666f722d7468652d6261646765)](https://github.com/Astrotomic/laravel-eloquent-uuid/blob/master/LICENSE)[![Offset Earth](https://camo.githubusercontent.com/d204555ebe1fb0ae82d10c97b4f4ffc2dfdd2ba1489f98be7f7e8708333a0466/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f54726565776172652d2546302539462538432542332d677265656e3f7374796c653d666f722d7468652d6261646765)](https://plant.treeware.earth/Astrotomic/laravel-eloquent-uuid)[![Larabelles](https://camo.githubusercontent.com/a2c8d5126ddd8c5ddc627176d1d2e0568f8399b50038e71fd7f774c3e24dbe4b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726162656c6c65732d2546302539462541362538342d6c6967687470696e6b3f7374796c653d666f722d7468652d6261646765)](https://www.larabelles.com/)

[![GitHub Workflow Status](https://camo.githubusercontent.com/a3044b3a45ab80987342273e83999a5a8ded1691c462d4bc619612bab9833ff9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f417374726f746f6d69632f6c61726176656c2d656c6f7175656e742d757569642f72756e2d74657374733f7374796c653d666c61742d737175617265266c6f676f436f6c6f723d7768697465266c6f676f3d676974687562266c6162656c3d5465737473)](https://github.com/Astrotomic/laravel-eloquent-uuid/actions?query=workflow%3Arun-tests)[![StyleCI](https://camo.githubusercontent.com/97cc7ac25683526874fd769482ea3554f41ba54048eba45191fc41702687f5da/68747470733a2f2f7374796c6563692e696f2f7265706f732f3234303733383831352f736869656c64)](https://styleci.io/repos/240738815)[![Total Downloads](https://camo.githubusercontent.com/2d618e170609f791acd22e23a09a3255fab8c884db6fcece03597ad6475403a1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f617374726f746f6d69632f6c61726176656c2d656c6f7175656e742d757569642e7376673f6c6162656c3d446f776e6c6f616473267374796c653d666c61742d737175617265)](https://packagist.org/packages/astrotomic/laravel-eloquent-uuid)

A simple drop-in solution for UUID support in your Eloquent models.

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

[](#installation)

You can install the package via composer:

```
composer require astrotomic/laravel-eloquent-uuid
```

Usage
-----

[](#usage)

You can use the provided `UsesUUID` trait to add an UUID attribute in addition to your normal primary key or use it as the primary key.

### Model

[](#model)

This will add an `uuid` attribute and auto-fill it before the model is created.

```
use Illuminate\Database\Eloquent\Model;
use App\Models\Concerns\UsesUUID;

class Post extends Model
{
    use UsesUUID;
}
```

If you want to customize the attribute name you can define a `$uuidName` property or override the `getUuidName()` method.

```
use Illuminate\Database\Eloquent\Model;
use App\Models\Concerns\UsesUUID;

class Post extends Model
{
    use UsesUUID;

    protected $uuidName = 'token';
}
```

And for sure you can use this trait to define your model primary key.

```
use Illuminate\Database\Eloquent\Model;
use App\Models\Concerns\UsesUUID;

class Post extends Model
{
    use UsesUUID;

    public $incrementing = false;

    protected $keyType = 'string';

    public function getUuidName(): string
    {
        return $this->getKeyName();
    }
}
```

### Migration

[](#migration)

Laravel provides an `uuid()` column type on the table `Blueprint` class.

```
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;

Schema::create('posts', function (Blueprint $table) {
    // ...
    $table->uuid('uuid')->unique();
    // ...
});
```

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

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

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

[](#contributing)

Please see [CONTRIBUTING](https://github.com/Astrotomic/.github/blob/master/CONTRIBUTING.md) for details. You could also be interested in [CODE OF CONDUCT](https://github.com/Astrotomic/.github/blob/master/CODE_OF_CONDUCT.md).

### Security

[](#security)

If you discover any security related issues, please check [SECURITY](https://github.com/Astrotomic/.github/blob/master/SECURITY.md) for steps to report it.

Credits
-------

[](#credits)

- [Tom Witkowski](https://github.com/Gummibeer)
- [All Contributors](../../contributors)

Alternatives
------------

[](#alternatives)

- [dyrynda/laravel-model-uuid](https://github.com/michaeldyrynda/laravel-model-uuid)
- [jamesmills/eloquent-uuid](https://github.com/jamesmills/eloquent-uuid)
- [goldspecdigital/laravel-eloquent-uuid](https://github.com/goldspecdigital/laravel-eloquent-uuid)

License
-------

[](#license)

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

Treeware
--------

[](#treeware)

You're free to use this package, but if it makes it to your production environment I would highly appreciate you buying the world a tree.

It’s now common knowledge that one of the best tools to tackle the climate crisis and keep our temperatures from rising above 1.5C is to [plant trees](https://www.bbc.co.uk/news/science-environment-48870920). If you contribute to my forest you’ll be creating employment for local families and restoring wildlife habitats.

You can buy trees at [offset.earth/treeware](https://plant.treeware.earth/Astrotomic/laravel-eloquent-uuid)

Read more about Treeware at [treeware.earth](https://treeware.earth)

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 95.1% 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 ~131 days

Recently: every ~188 days

Total

7

Last Release

1492d ago

PHP version history (3 changes)1.0.0PHP ^7.2

1.4.0PHP ^7.3 || ^8.0

1.5.0PHP ^7.4 || ^8.0

### Community

Maintainers

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

---

Top Contributors

[![Gummibeer](https://avatars.githubusercontent.com/u/6187884?v=4)](https://github.com/Gummibeer "Gummibeer (78 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (1 commits)")[![jamesmills](https://avatars.githubusercontent.com/u/557096?v=4)](https://github.com/jamesmills "jamesmills (1 commits)")[![mstaack](https://avatars.githubusercontent.com/u/10169509?v=4)](https://github.com/mstaack "mstaack (1 commits)")[![tomhatzer](https://avatars.githubusercontent.com/u/3952168?v=4)](https://github.com/tomhatzer "tomhatzer (1 commits)")

---

Tags

eloquenthacktoberfestlaraveltreewareuuidlaraveleloquentuuidastrotomiclaravel-eloquent-uuid

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[weebly/laravel-mutate

Mutate Laravel attributes

1354.7k](/packages/weebly-laravel-mutate)

PHPackages © 2026

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