lasthourcloud/app/Models/BaseModel.php

22 lines
424 B
PHP
Raw Permalink Normal View History

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Visus\Cuid2\Cuid2;
abstract class BaseModel extends Model
{
protected static function boot()
{
parent::boot();
static::creating(function (Model $model) {
2023-05-09 12:42:10 +00:00
// Generate a UUID if one isn't set
2024-06-10 20:43:34 +00:00
if (! $model->uuid) {
$model->uuid = (string) new Cuid2(7);
2023-05-09 12:42:10 +00:00
}
});
}
}