mdbpanel/app/Traits/Uuid.php

22 lines
327 B
PHP

<?php
namespace App\Traits;
use Illuminate\Support\Str;
trait Uuids
{
/**
* Boot function from laravel.
*/
protected static function boot()
{
parent::boot();
static::creating(function ($model) {
$model->{$model->getKeyName()} = (string) Str::uuid();
});
}
}
?>