glorand/laravel-eloquent-model-uuid

A simple solution for providing UUID support for the IDs of your Eloquent models.
1,023 3
Install
composer require glorand/laravel-eloquent-model-uuid
Latest Version:4.0.0
PHP:>=7.1.3
License:MIT
Last Updated:Oct 5, 2025
Links: GitHub  ·  Packagist
Maintainer: glorand

Laravel eloquent model uuid

Latest Stable Version Build Status Software License StyleCI Code Intelligence Status Scrutinizer Code Quality Code Coverage

A simple solution for providing UUID support for the IDs of your Eloquent models.

Installation

You can install the package via composer:

composer require glorand/laravel-eloquent-model-uuid

Usage

Let us start on the database side of things.

$table->uuid('id');
$table->primary('id');
//OR
$table->uuid('id')->primary();

Use model class provided by this package

Instead of extending the standard Laravel model class, extend from the model class provided by this package:

<?php
use Glorand\LaravelEloquentModelUuid\Database\Eloquent\Model;

class Entity extends Model
{
    //
}

Use Trait on model class:

<?php
use Illuminate\Database\Eloquent\Model;
use Glorand\LaravelEloquentModelUuid\Database\Concerns\Uuid;

class Entity extends Model
{
    use Uuid;
    
    /**
     * The "type" of the auto-incrementing ID.
     *
     * @var string
     */
    protected $keyType = 'string';

    /**
     * Indicates if the IDs are auto-incrementing.
     *
     * @var bool
     */
    public $incrementing = false;
    //
}

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email gombos.lorand@gmail.com instead of using the issue tracker.

License

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

Related Packages

eig/eloquent-uuid

Easy UUID for Eloquent Models

1,653 59
gbuckingham89/eloquent-uuid

A simple package for using UUID's (UUID4) with Laravel's Eloquent.

4,787 1
dyrynda/laravel-model-uuid

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

3,308,755 484
theprivateer/eloquent-uuid

UUID utility traits for Laravel

7,181 1
peach-schnapps/eloquent-uuid

Provides UUID Support for Laravel 4 Eloquent Models

6 2