kfoobar/laravel-uuid

UUID Trait for Eloquent Models in Laravel
3,060
Install
composer require kfoobar/laravel-uuid
Latest Version:v2.0.0
PHP:^8.0
License:MIT
Last Updated:Sep 21, 2026
Links: GitHub  ·  Packagist
Maintainer: KFoobar

Laravel UUID Trait for Eloquent Models

Enhance your Laravel models with UUID functionality seamlessly using our trait, compatible with Laravel 9 and newer versions. Use version 1 for Laravel 5.6 to 8.

Installation Guide

Install the package through Composer with the following command:

composer require kfoobar/laravel-uuid

How to Use

To integrate UUIDs into your models, simply use the KFoobar\Uuid\Traits\HasUuid trait in your model class like so:

use Illuminate\Database\Eloquent\Model;
use KFoobar\Uuid\Traits\HasUuid;

class Post extends Model
{
    use HasUuid;
}

This will automatically generate a UUID for each new model instance.

Custom Column Name

The UUID is stored in the uuid column by default. To use another column, define a UUID constant on your model:

class Post extends Model
{
    use HasUuid;

    const UUID = 'public_id';
}

Contributing

We encourage contributions from the community! Whether it's improving the code, fixing bugs, or enhancing documentation, your input is valuable.

License

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

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

641,106,524 9,700
laravel/framework

The Laravel Framework.

593,882,149 34,959
laravel/tinker

Powerful REPL for the Laravel framework.

502,645,077 7,441
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

418,291,778 609
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

394,964,158 4,660

Version History

Version Released PHP Laravel License
v2.0.0 ^8.0 ^9.0|^10.0|^11.0|^12.0|^13.0 MIT
v1.1.0 ^7.3|^8.0 ^5.6|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0|^13.0 MIT
v1.0.3 ^7.3|^8.0 ^5.5|^6.0|^7.0|^8.0|^9.0|^10.0 MIT
v1.0.2 ^7.3|^8.0 >=5.5 MIT
v1.0.1 ^7.3|^8.0 >=5.5 MIT