Adedoyin Akande
Jan 21, 2021

--

For Laravel 8, the boot function could simply be:

static::creating(function ($model) {

$model->keyType = 'string';

$model->incrementing = false;

$model->{$model->getKeyName()} = $model->{$model->getKeyName()} ?: (string) Str::orderedUuid();

});

This avoids the infinite loop at -> parent::boot();

And also keep things simple.

--

--

Adedoyin Akande
Adedoyin Akande

Responses (1)