lucasmichot / eloquentuuid by lucasmichot

Provides a unique Base62-encoded UUID representing a given state of a model instance
17
2
3
Package Data
Maintainer Username: lucasmichot
Maintainer Contact: lucas@semalead.com (Lucas Michot)
Package Create Date: 2014-06-30
Package Last Update: 2014-07-21
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-04-18 15:00:24
Package Statistics
Total Downloads: 17
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 2
Total Watchers: 3
Total Forks: 1
Total Open Issues: 0

EloquentUUID

Provides a unique Base62-encoded UUID representing a given state of a model instance.

This is particularly useful to keep track of model versions.

Why Base62 ?

Compared to MD5, a Base62 hash is shorter and the alphabet used makes it cleaner to process, when used in a shorten URL for instance, or when stored in a database.

Requirements:

Package installation

Begin by installing this package through Composer. Edit your project's composer.json file to require lucasmichot/eloquentuuid.

"require": {
  "lucasmichot/eloquentuuid": "0.*"
}

Next, update Composer from the Terminal:

$ composer update

You can achieve these operations with this one-liner command :

$ composer require "lucasmichot/eloquentuuid:0.*"

Usage

use Lucasmichot\Eloquentuuid\UuidTrait;

class Post extends Eloquent
{
    use UuidTrait;

    // the code of your model comes here
}

Accessing the UUID :

$post = Post::find(1);
// update the attributes of the post

echo $post->uuid();

Each time the model is modified, the UUID is changed accordingly.

TODO

  • [ ] Finish documentation