DEV Community

Discussion on: Easily use UUIDs in Laravel

Collapse
 
bodrosh profile image
Bodrosh

I also encountered this problem, if you want to add a uuid to the table additionally when it already has a key, you can do this:

protected static function bootUsesUuid() {
static::creating(function ($model) {
if (! $model->uuid) {
$model->uuid = (string) Str::uuid();
}
});
}