Corrected Uuid Trait Errors
This commit is contained in:
21
app/Models/Uuids.php
Normal file
21
app/Models/Uuids.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Webpatser\Uuid\Uuid;
|
||||
|
||||
trait Uuids
|
||||
{
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::creating(function ($model) {
|
||||
$key = $model->getKeyName();
|
||||
if (empty($model->{$key})) {
|
||||
$model->{$key} = Uuid::generate()->string;
|
||||
}
|
||||
#$model->{$model->getKeyName()} = Uuid::generate()->string;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user