Skip to content

Commit 93c5d30

Browse files
committed
clean uuid
1 parent 5243d89 commit 93c5d30

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/Concerns/HasUuid.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,17 @@
44

55
namespace Elegantly\Conversation\Concerns;
66

7-
use Illuminate\Database\Eloquent\Model;
87
use Illuminate\Support\Str;
98

109
/**
11-
* @property ?string $uuid
10+
* @property string $uuid
1211
*/
1312
trait HasUuid
1413
{
15-
public static function bootHasUuid(): void
14+
public function initializeHasUuid(): void
1615
{
17-
static::creating(function (Model $model) {
18-
if (empty($model->uuid)) {
19-
$model->uuid = (string) Str::uuid(); // @phpstan-ignore-line
20-
}
21-
});
16+
if (blank($this->uuid)) {
17+
$this->uuid = (string) Str::uuid();
18+
}
2219
}
2320
}

0 commit comments

Comments
 (0)