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

ActiveLibrary

mawuekom/laravel-model-uuid
===========================

Easily work with UUIDs in your Laravel models

v2.3.0(2y ago)12122MITPHPPHP ^7.2|^7.3|^7.4|^8.0|^8.1|^8.2|^8.3

Since Jun 16Pushed 2y ago1 watchersCompare

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

READMEChangelog (2)Dependencies (4)Versions (14)Used By (2)

Laravel Model UUIDs
===================

[](#laravel-model-uuids)

[![Latest Version on Packagist](https://camo.githubusercontent.com/fbdea8f7ceae0b6de296520ab57409f7c0e617b5ebacc23ae946273ecee7972d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d617775656b6f6d2f6c61726176656c2d6d6f64656c2d757569642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mawuekom/laravel-model-uuid)[![Total Downloads](https://camo.githubusercontent.com/8f592d936f703b38f2d0af68e375c5d6c74684eebecfe4d92638d27270e18250/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d617775656b6f6d2f6c61726176656c2d6d6f64656c2d757569642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mawuekom/laravel-model-uuid)[![GitHub Actions](https://github.com/mawuva/laravel-model-uuid/actions/workflows/main.yml/badge.svg)](https://github.com/mawuva/laravel-model-uuid/actions/workflows/main.yml/badge.svg)

A simple solution to easily work with UUIDs in your Laravel models.

This package provides a way to generate and work with [RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122) version 1, 2, 3, 4, and 5 universally unique identifiers (UUID). It also supports optional and non-standard features, such as \[version 6 UUIDs\], GUIDs, and other approaches for encoding/decoding UUIDs.

It based on [ramsey/uuid](https://uuid.ramsey.dev/en/latest/index.html) package.
Take a look on this for more details.

What Is a UUID?
---------------

[](#what-is-a-uuid)

A universally unique identifier, or UUID, is a 128-bit unsigned integer, usually represented as a hexadecimal string split into five groups with dashes. The most widely-known and used types of UUIDs are defined by [RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122).

A UUID, when encoded in hexadecimal string format, looks like:

```
ebb5c735-0308-4edc-9aea-8a270aebfe15

```

The probability of duplicating a UUID is close to zero, so they are a great choice for generating unique identifiers in distributed systems.

UUIDs can also be stored in binary format, as a string of 16 bytes.

It is suggested to use UUIDs in your responses instead of IDs, which are generally enumerable.

This will help mitigate some forms of enumeration attacks.

**Note**: This package explicitly does not disable auto-incrementing on your Eloquent models. In terms of database indexing, it is generally more efficient to use auto-incrementing integers for your internal querying. Indexing your uuid column will make lookups against that column fast, without impacting queries between related models.

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

[](#installation)

You can install the package via composer:

```
composer require mawuekom/laravel-model-uuid
```

Usage
-----

[](#usage)

To use this package, you simply need to import and use the trait within your Eloquent models.

```
