Skip to content

A trait to use Laravel native UUID functionality

License

Notifications You must be signed in to change notification settings

LuminFire/laravel-uuid

 
 

Repository files navigation

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')

About

A trait to use Laravel native UUID functionality

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%