PHPackages                             gbuckingham89/eloquent-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. gbuckingham89/eloquent-uuid

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

gbuckingham89/eloquent-uuid
===========================

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

3.5.0(2y ago)14.8k↓100%1MITPHPPHP ^7.1|^8.0CI failing

Since Jan 25Pushed 2y ago1 watchersCompare

[ Source](https://github.com/gbuckingham89/eloquent-uuid)[ Packagist](https://packagist.org/packages/gbuckingham89/eloquent-uuid)[ Docs](https://github.com/gbuckingham89/eloquent-uuid)[ RSS](/packages/gbuckingham89-eloquent-uuid/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (5)Dependencies (1)Versions (10)Used By (0)

gbuckingham89/eloquent-uuid v3
==============================

[](#gbuckingham89eloquent-uuid-v3)

A simple package for using UUID's with Laravel's Eloquent models. By including the trait on your models, they will automatically get given a time ordered UUIDv4 for their key (ID) when being persisted to the database.

The current version requires Laravel 5.6 (PHP 7.1) or greater. *If you're using an older version of Laravel, please see [v1](https://github.com/gbuckingham89/eloquent-uuid/tree/1.0.1) of this package.*

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

[](#installation)

```
composer require gbuckingham89/eloquent-uuid

```

Use
---

[](#use)

Make sure your database table(s) are setup to handle UUID's. Laravel has a method called `uuid()` which you can use in your migrations. You will probably want the field to be unique too.

```
Schema::create('users', function (Blueprint $table) {
    $table->uuid('id')->unique();
    // Other fields here...
});

```

At the top of your model(s) you simply need to include a trait:

```
