PHPackages                             mindtwo/laravel-auto-create-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. mindtwo/laravel-auto-create-uuid

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

mindtwo/laravel-auto-create-uuid
================================

Automatically generate UUIDs for Eloquent models on creation and replication.

3.0(1mo ago)123.8k13MITPHPPHP ^8.2CI passing

Since Dec 4Pushed 1mo ago4 watchersCompare

[ Source](https://github.com/mindtwo/laravel-auto-create-uuid)[ Packagist](https://packagist.org/packages/mindtwo/laravel-auto-create-uuid)[ GitHub Sponsors]()[ RSS](/packages/mindtwo-laravel-auto-create-uuid/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (4)Dependencies (10)Versions (18)Used By (3)

Laravel Auto Create UUID
========================

[](#laravel-auto-create-uuid)

[![Latest Stable Version](https://camo.githubusercontent.com/f1c561c42124a86b129ec9597596896e59c8541a5a5106a8fb95999450cb5e50/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d696e6474776f2f6c61726176656c2d6175746f2d6372656174652d757569643f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mindtwo/laravel-auto-create-uuid)[![run-tests](https://camo.githubusercontent.com/a2b4b31a0e018ea4e6df8dae60624c3ccf41c91303c1f65b9ab62ddc0c42b7cb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d696e6474776f2f6c61726176656c2d6175746f2d6372656174652d757569642f72756e2d74657374732e796d6c3f6272616e63683d6d6173746572266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/mindtwo/laravel-auto-create-uuid/actions/workflows/run-tests.yml)[![PHPStan](https://camo.githubusercontent.com/1b051e0c4e03c06538a9dd507cf5893671f921bd65c05dbdfc36d61fec07dc46/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d696e6474776f2f6c61726176656c2d6175746f2d6372656174652d757569642f7068707374616e2e796d6c3f6272616e63683d6d6173746572266c6162656c3d7068707374616e267374796c653d666c61742d737175617265)](https://github.com/mindtwo/laravel-auto-create-uuid/actions/workflows/phpstan.yml)[![Total Downloads](https://camo.githubusercontent.com/70c66e1a0ebf4668c43816558276cca422a702075b1218ed3277ed1d378906e3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d696e6474776f2f6c61726176656c2d6175746f2d6372656174652d757569643f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mindtwo/laravel-auto-create-uuid)[![License](https://camo.githubusercontent.com/107d95f1eb16bba18181f6830fbb46af5113160fb07ee3f6f2ad52ba5af5ad0c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d696e6474776f2f6c61726176656c2d6175746f2d6372656174652d757569643f7374796c653d666c61742d737175617265)](LICENSE.md)

Automatically populate a UUID column on Eloquent models when they are created or replicated. Drop the trait onto any model and the rest works without configuration.

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

[](#installation)

Install the package via Composer:

```
composer require mindtwo/laravel-auto-create-uuid
```

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 10, 11, 12, or 13

Usage
-----

[](#usage)

### Add the trait to a model

[](#add-the-trait-to-a-model)

```
use Illuminate\Database\Eloquent\Model;
use mindtwo\LaravelAutoCreateUuid\AutoCreateUuid;

class Example extends Model
{
    use AutoCreateUuid;
}
```

### Add a UUID column to the migration

[](#add-a-uuid-column-to-the-migration)

```
$table->uuid('uuid')->unique();
```

The trait listens to the `creating` and `replicating` model events and fills the configured UUID column with a new UUID v4 whenever the column is empty or holds an invalid UUID.

### Customize the UUID column

[](#customize-the-uuid-column)

The default column name is `uuid`. To use a different column, either define a `$uuid_column` property:

```
class Example extends Model
{
    use AutoCreateUuid;

    protected string $uuid_column = 'identifier';
}
```

or override the `getUuidColumn()` method:

```
class Example extends Model
{
    use AutoCreateUuid;

    public function getUuidColumn(): string
    {
        return 'identifier';
    }
}
```

### Replicating models

[](#replicating-models)

The trait overrides `Model::replicate()` to ensure the UUID column is excluded from the cloned attributes, so the replica receives a fresh UUID via the `replicating` event.

Testing
-------

[](#testing)

```
composer test
```

Static analysis
---------------

[](#static-analysis)

```
composer analyse
```

Code style
----------

[](#code-style)

```
composer format
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for a list of recent changes.

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

[](#contributing)

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

Security
--------

[](#security)

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

Credits
-------

[](#credits)

- [mindtwo GmbH](https://github.com/mindtwo)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

60

—

FairBetter than 98% of packages

Maintenance93

Actively maintained with recent releases

Popularity30

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity83

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 51.6% 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 ~194 days

Recently: every ~204 days

Total

15

Last Release

36d ago

Major Versions

1.0 → 2.0.02019-08-29

2.6.5 → 3.02026-05-21

PHP version history (8 changes)1.0PHP ^7.1.3

2.1.0PHP ^7.2

2.3PHP ^7.3

2.3.1PHP ^7.0|^8.0

2.6PHP ^7.0|^8.0|^8.1

2.6.3PHP ^8.0|^8.1|^8.2|^8.3|^8.4

2.6.5PHP ^8.0|^8.1|^8.2|^8.3|^8.4|^8.5

3.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/4cc86fe6179314d204b14d1c81eb09a87ef84b0bcf2360dcd981171d1346c077?d=identicon)[mindtwo](/maintainers/mindtwo)

---

Top Contributors

[![blumewas](https://avatars.githubusercontent.com/u/5960093?v=4)](https://github.com/blumewas "blumewas (32 commits)")[![jonasemde](https://avatars.githubusercontent.com/u/5083193?v=4)](https://github.com/jonasemde "jonasemde (25 commits)")[![tkivelip](https://avatars.githubusercontent.com/u/3762670?v=4)](https://github.com/tkivelip "tkivelip (4 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (1 commits)")

---

Tags

laravelmodeleloquenttraituuid

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/mindtwo-laravel-auto-create-uuid/health.svg)

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

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.0M87](/packages/mongodb-laravel-mongodb)[dyrynda/laravel-model-uuid

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

4833.0M9](/packages/dyrynda-laravel-model-uuid)[cybercog/laravel-love

Make Laravel Eloquent models reactable with any type of emotions in a minutes!

1.2k322.4k1](/packages/cybercog-laravel-love)[spiritix/lada-cache

A Redis based, automated and scalable database caching layer for Laravel

591452.8k2](/packages/spiritix-lada-cache)[esensi/model

The base model traits of Esensi

20067.0k1](/packages/esensi-model)[highsolutions/eloquent-sequence

A Laravel package for easy creation and management sequence support for Eloquent models with elastic configuration.

121134.8k](/packages/highsolutions-eloquent-sequence)

PHPackages © 2026

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