18 lines
296 B
PHP
Executable File
18 lines
296 B
PHP
Executable File
<?php
|
|
|
|
namespace App\Traits;
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
trait HasUuid
|
|
{
|
|
public static function bootHasUuid(): void
|
|
{
|
|
static::creating(function ($model) {
|
|
if (!$model->uuid) {
|
|
$model->uuid = Str::uuid()->toString();
|
|
}
|
|
});
|
|
}
|
|
}
|