2017 © Pedro Peláez
 

library laravel-uuid

Adds a uuid to a model using ramsey/uuid

image

jenbuzz/laravel-uuid

Adds a uuid to a model using ramsey/uuid

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 100 % Grown

The README.md

Build Status, (*1)

Laravel UUID

This package easily adds a uuid generated with ramsey/uuid to an Eloquent model., (*2)

Installation

composer require jenbuzz/laravel-uuid, (*3)

Documentation

To automatically create a uuid for new models all that is needed is to include the uuid trait as in the following example:, (*4)

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Jenbuzz\LaravelUuid\Traits\Uuid;

class MyModel extends Model
{
    use Uuid;
}

There are several options to specify the uuid that should be generated: 'uuidVersion', 'uuidString', 'uuidColumnName', and 'uuidGenerateOnSave'. But first..., (*5)

Default values are: - uuidVersion = 4 - uuidString = '' - uuidColumnName = 'uuid' - uuidGenerateOnSave = false, (*6)

The last option, 'uuidGenerateOnSave', will generate a uuid for the element on the next save action if set to true. This could be useful if uuids were introduced later on and existing elements require an uuid., (*7)

To change these options they can be specified through class properties in the model as in the following example:, (*8)

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Jenbuzz\LaravelUuid\Traits\Uuid;

class MyModel extends Model
{
    use Uuid;

    protected $uuidVersion = 5;
    protected $uuidString = 'lorem';
    protected $uuidColumnName = 'my_uuid';
    protected $uuidGenerateOnSave = true;
}

The uuid trait also adds a 'find'-function to the model which makes it is easy to find an element by uuid. This can be done as in the following code snippet:, (*9)

<?php

$element = MyModel::findByUuid('3059dbe0-20d4-4591-9b02-1f77a1826544');

License

This package is open-sourced software licensed under the MIT license, (*10)

The Versions

06/06 2018

dev-master

9999999-dev

Adds a uuid to a model using ramsey/uuid

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel uuid eloquent universally unique identifier ramsey uuid

26/05 2018

1.0.0

1.0.0.0

Adds a uuid to a model using ramsey/uuid

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel uuid eloquent universally unique identifier ramsey uuid

15/05 2018

0.0.1

0.0.1.0

Adds a uuid to a model using ramsey/uuid

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel uuid eloquent universally unique identifier ramsey uuid