Commit 1ed56c77 by Aan Choesni Herlingga

added UuidTrait

parent a247a858
<?php
namespace App\Http\Traits;
use Illuminate\Support\Str;
trait UuidTrait
{
/**
* Boot function from Laravel
*/
protected static function boot()
{
parent::boot();
static::creating(function ($model) {
$model->incrementing = false;
$model->keyType = 'string';
$model->{$model->getKeyName()} = Str::uuid()->toString();
});
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment