edersoares / eloquent-uuid

A simple package to use universally unique identifiers (UUID) in Eloquent models.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Eloquent UUID

A simple package to use universally unique identifiers (UUID) as primary key of the Eloquent models.

This package uses Uuid library utilized in Laravel Framework to generate UUIDs.

Installation

composer require edersoares/eloquent-uuid

Usage

  • Replace in migrations files:
// From
$table->increments('id');

// To
$table->uuid('uuid')->unique();
$table->primary('uuid')
  • After, use in your model the Nix\Eloquent\Uuid\Uuid trait:
use Illuminate\Database\Eloquent\Model;
use Nix\Eloquent\Uuid\Uuid;

class SomeModel extends Model
{
    use Uuid;
}

Credits

This package uses:

And is based on:

About

A simple package to use universally unique identifiers (UUID) in Eloquent models.

License:MIT License


Languages

Language:PHP 100.0%