2017 © Pedro Peláez
 

library uniquely

Uniquely identified models for Laravel 4 by using UUID as primary key

image

lukaskorl/uniquely

Uniquely identified models for Laravel 4 by using UUID as primary key

  • Saturday, July 26, 2014
  • by lukaskorl
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1,956 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Uniquely identified models for Laravel 4

Uniquely uses UUIDv4 as primary key for Laravel 4 Eloquent models. It automatically generates the UUID when your model is saved. Uniquely overwrites the save() method instead of attaching to Eloquent's creating event in order to circumvent some problems in combination with unit testing., (*1)

Installation

To install Uniquely run, (*2)

$ composer require lukaskorl/uniquely

You can specify 1.* to include the most current version including possible future bugfixes., (*3)

Manual installation, (*4)

If you choose to install Uniquely manually add the following line to your composer.json:, (*5)

"require": {
    "lukaskorl/uniquely": "1.*"
}

and run, (*6)

$ composer update

to install the package., (*7)

Usage

To use a Uniquely model simply extend your model class from Lukaskorl\Uniquely\Model., (*8)

<?php

use Lukaskorl\Uniquely\Model;

class User extends Model {

}

Proper database migrations

The id field of the corresponding database table for your model should be a 36-char string (i.e. VARCHAR(36)). If you are using Laravel 4 migrations you will have to set your id field like so:, (*9)

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class CreateUsersTable extends Migration {

    public function up()
    {
        Schema::create('users', function(Blueprint $table)
        {
            $table->string('id', 36);
            // ... other columns ...
            $table->timestamps();
        });

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


    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('users');
    }
}

License

Uniquely is open-sourced software licensed under the MIT license., (*10)

The Versions

26/07 2014

dev-master

9999999-dev

Uniquely identified models for Laravel 4 by using UUID as primary key

  Sources   Download

MIT

The Requires

 

laravel uuid model unique

26/07 2014

v1.0

1.0.0.0

Uniquely identified models for Laravel 4 by using UUID as primary key

  Sources   Download

MIT

The Requires

 

laravel uuid model unique

26/07 2014

v0.3

0.3.0.0

Uniquely identified models for Laravel 4 by using UUID as primary key

  Sources   Download

MIT

The Requires

 

laravel uuid model unique

10/06 2014

v0.2

0.2.0.0

Uniquely identified models for Laravel 4

  Sources   Download

MIT

The Requires

 

laravel uuid model unique

09/06 2014

v0.1

0.1.0.0

Uniquely identified models for Laravel 4

  Sources   Download

MIT

The Requires

 

laravel uuid model unique