2024-08-29 11:48:10 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App;
|
2024-08-30 09:37:24 +02:00
|
|
|
|
2024-08-29 11:48:10 +02:00
|
|
|
use Ramsey\Uuid\Uuid;
|
|
|
|
|
|
|
|
trait UuidId
|
|
|
|
{
|
2024-08-30 09:37:24 +02:00
|
|
|
protected static function boot()
|
|
|
|
{
|
2024-08-29 11:48:10 +02:00
|
|
|
parent::boot();
|
|
|
|
static::creating(function ($model) {
|
|
|
|
$model->id = Uuid::uuid6()->toString();
|
|
|
|
});
|
|
|
|
}
|
2024-08-30 09:40:57 +02:00
|
|
|
|
2024-08-30 09:37:24 +02:00
|
|
|
public function getIncrementing(): bool
|
|
|
|
{
|
2024-08-29 11:48:10 +02:00
|
|
|
return false;
|
|
|
|
}
|
2024-08-30 09:40:57 +02:00
|
|
|
|
2024-08-30 09:37:24 +02:00
|
|
|
public function getKeyType(): string
|
|
|
|
{
|
2024-08-29 11:48:10 +02:00
|
|
|
return 'string';
|
|
|
|
}
|
|
|
|
}
|