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

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

centrex/laravel-uuid
====================

Add uuid with model in laravel

v1.2.0(1y ago)02[1 PRs](https://github.com/centrex/laravel-uuid/pulls)MITPHPPHP ^8.2|^8.3|^8.4CI passing

Since Nov 20Pushed 1w agoCompare

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

READMEChangelogDependencies (14)Versions (11)Used By (0)

UUID trait for Laravel Eloquent models
======================================

[](#uuid-trait-for-laravel-eloquent-models)

[![Latest Version on Packagist](https://camo.githubusercontent.com/6f7f65c176a473fd29be34565a23904f259006902f8f2aa89572a3693558c378/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f63656e747265782f6c61726176656c2d757569642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/centrex/laravel-uuid)[![GitHub Tests Action Status](https://camo.githubusercontent.com/b91b51f2d2d0e2c553a1d330ae413e08f61846a7b995e1d9c9db9fe506107d12/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f63656e747265782f6c61726176656c2d757569642f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/centrex/laravel-uuid/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/b05ca5f569dce476a64929672806a806d18199bb7fc98b5d783720e0d65e6517/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f63656e747265782f6c61726176656c2d757569642f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/centrex/laravel-uuid/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/41bf48ddbaea805ebbcb3ecf11e0e027e2c41f366e6ed4bc1f045ad9413caad7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f63656e747265782f6c61726176656c2d757569643f7374796c653d666c61742d737175617265)](https://packagist.org/packages/centrex/laravel-uuid)

Auto-generates a UUID v4 on model creation, sets it as the route key, and provides a query scope for UUID lookups.

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

[](#installation)

```
composer require centrex/laravel-uuid
```

Usage
-----

[](#usage)

### 1. Add the column to your migration

[](#1-add-the-column-to-your-migration)

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

### 2. Add the trait to your model

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

```
use Centrex\LaravelUuid\HasUuid;

class Order extends Model
{
    use HasUuid;
}
```

A UUID is automatically generated on `creating` if the `uuid` column is present and empty.

### 3. Route model binding

[](#3-route-model-binding)

The trait overrides `getRouteKeyName()` to return `'uuid'`, so route model binding works out of the box:

```
// routes/web.php
Route::get('/orders/{order}', [OrderController::class, 'show']);
// URL: /orders/550e8400-e29b-41d4-a716-446655440000
```

### 4. Query scope

[](#4-query-scope)

```
Order::uuid('550e8400-e29b-41d4-a716-446655440000')->first();
```

### Custom column name

[](#custom-column-name)

Override `$uuid_column` on the model or publish the config:

```
class Order extends Model
{
    use HasUuid;

    protected $uuid_column = 'public_id';
}
```

```
php artisan vendor:publish --tag="laravel-uuid-config"
```

Testing
-------

[](#testing)

```
composer test        # full suite
composer test:unit   # pest only
composer test:types  # phpstan
composer lint        # pint
```

Changelog
---------

[](#changelog)

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

Credits
-------

[](#credits)

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

License
-------

[](#license)

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

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance72

Regular maintenance activity

Popularity2

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 63.5% 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 ~110 days

Total

5

Last Release

512d ago

PHP version history (3 changes)v1.0.0PHP ^8.0|^8.1

v1.0.1PHP ^8.1|^8.2

v1.1.0PHP ^8.2|^8.3|^8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/29769944?v=4)[Raisul Islam](/maintainers/rochi88)[@rochi88](https://github.com/rochi88)

---

Top Contributors

[![rochi88](https://avatars.githubusercontent.com/u/29769944?v=4)](https://github.com/rochi88 "rochi88 (40 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (15 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (8 commits)")

---

Tags

laravellaravel-uuidcentrex

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-medialibrary

Associate files with Eloquent models

6.1k43.2M626](/packages/spatie-laravel-medialibrary)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.4M94](/packages/mongodb-laravel-mongodb)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8793.2M25](/packages/yajra-laravel-oci8)[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

1.6k32.6M46](/packages/kirschbaum-development-eloquent-power-joins)[glushkovds/phpclickhouse-laravel

Adapter of the most popular library https://github.com/smi2/phpClickHouse to Laravel

2051.5M1](/packages/glushkovds-phpclickhouse-laravel)

PHPackages © 2026

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