Corrected Uuid Trait Errors

This commit is contained in:
Kyle
2017-08-12 16:46:05 +00:00
parent 738cd15db4
commit afc3e7643d
4 changed files with 20 additions and 0 deletions

21
app/Models/Uuids.php Normal file
View File

@@ -0,0 +1,21 @@
<?php
namespace App\Models;
use Webpatser\Uuid\Uuid;
trait Uuids
{
protected static function boot()
{
parent::boot();
static::creating(function ($model) {
$key = $model->getKeyName();
if (empty($model->{$key})) {
$model->{$key} = Uuid::generate()->string;
}
#$model->{$model->getKeyName()} = Uuid::generate()->string;
});
}
}