18 lines
311 B
PHP
18 lines
311 B
PHP
<?php
|
|
|
|
namespace App\Models\Concerns;
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
trait HasUuid
|
|
{
|
|
protected static function bootHasUuid(): void
|
|
{
|
|
static::creating(function ($model) {
|
|
if (empty($model->uuid)) {
|
|
$model->uuid = (string) Str::uuid();
|
|
}
|
|
});
|
|
}
|
|
}
|