Skip to content

Files

Latest commit

 

History

History
48 lines (31 loc) · 1.32 KB

README.md

File metadata and controls

48 lines (31 loc) · 1.32 KB

Laravel-UUID

Build Status Latest Stable Version Total Downloads

A trait to add UUID integration, using Laravel’s native Str:uuid() functionality. Forked from binarycabin/laravel-uuid, removing the webpatser/laravel-uuid dependency.

composer require luminfire/laravel-uuid

This package adds a very simple trait to automatically generate a UUID for your Models.

Simply add the \LuminFire\LaravelUUID\Traits\HasUUID; trait to your model:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Project extends Model
{

    use \LuminFire\LaravelUUID\Traits\HasUUID;

}

If your column name is not "uuid", simply add a new property to your model named "uuidFieldName":

protected $uuidFieldName = 'unique_id';

This trait also adds a scope:

\App\Project::byUUID('uuid')->first();

And static find method:

\App\Project::findByUUID('uuid')