Skip to content

Simply create Eloquent Models & database tables with UUID/GUID primary keys.

Notifications You must be signed in to change notification settings

michalkortas/laravel-uuid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

laravel-uuid

Simply create Eloquent Models & database tables with UUID/GUID primary keys.

Installation

composer require michalkortas/laravel-uuid

Usage

Add uuid as primary key in your table migration.

Schema::create('customers', function (Blueprint $table) {
    $table->uuid('id')->primary();
});

Add trait to your Eloquent Model.

<?php

namespace AppModels;

use michalkortas\LaravelUuid\traits\HasUuid;
use Illuminate\Database\Eloquent\Model;

class Customers extends Model
{
    use HasUuid;
}

Now, when you run migrations, newly created table has datatype ID as CHAR(36). UUID will be inserted automatically with Model::create() method.

ID datatype - UUID - CHAR(36)

About

Simply create Eloquent Models & database tables with UUID/GUID primary keys.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages