2017 © Pedro Peláez
 

library has-uuid

Use both auto-increment and UUID

image

rap2hpoutre/has-uuid

Use both auto-increment and UUID

  • Monday, February 19, 2018
  • by rap2hpoutre
  • Repository
  • 1 Watchers
  • 0 Stars
  • 309 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 4 % Grown

The README.md

HasUuid Trait

What?

Why choose between Seq ID (aka auto-increment) and UUID when you can use both? This package helps you to add UUID to your Laravel Models., (*1)

You can also use this class if you only wants UUID without increments., (*2)

Quick start

Install with composer:, (*3)

composer require rap2hpoutre/has-uuid

Add the trait to your models:, (*4)

<?php
class User {

    use \Rap2hpoutre\HasUuid\HasUuid;

    // ...
}

Use the Trait to load your models:, (*5)

$user = User::uuid('e3ae1e6b-fabb-4839-bf65-de9a892c0d56');

And when you save a model, it will magically add a UUID to it:, (*6)

$user = new User;
$user->name = 'raph';
$user->save(); // <- Your user has now a UUID (and a ID if you have not removed it)

PS: don't forget to add the UUID in your migrations:, (*7)

<?php   
   class CreateSesNotificationsTable extends \Illuminate\Database\Migrations\Migration
   {
       public function up()
       {
           \Schema::create('user', function ($table) {
               $table->increments('id');
               $table->uuid('uuid')->index(); // <- THIS.
               $table->string('email')->index();
               $table->timestamps();
           });
       }
       // ...
   }

The Versions

19/02 2018

dev-master

9999999-dev

Use both auto-increment and UUID

  Sources   Download

MIT

The Requires

 

by rap2h

laravel uuid library trait package

19/02 2018

v0.0.6

0.0.6.0

Use both auto-increment and UUID

  Sources   Download

MIT

The Requires

 

by rap2h

laravel uuid library trait package

11/10 2017

v0.0.5

0.0.5.0

Use both auto-increment and UUID

  Sources   Download

MIT

The Requires

 

by rap2h

laravel uuid library trait package

11/10 2017

v0.0.4

0.0.4.0

Use both auto-increment and UUID

  Sources   Download

MIT

The Requires

 

by rap2h

laravel uuid library trait package

04/10 2017

v0.0.3

0.0.3.0

Use both auto-increment and UUID

  Sources   Download

MIT

The Requires

 

by rap2h

laravel uuid library trait package

04/10 2017

v0.0.2

0.0.2.0

Use both auto-increment and UUID

  Sources   Download

MIT

The Requires

 

by rap2h

laravel uuid library trait package

04/10 2017

v0.0.1

0.0.1.0

Use both auto-increment and UUID

  Sources   Download

MIT

The Requires

 

by rap2h

laravel uuid library trait package