PATH:
home
/
lab2454c
/
tripvare.com
/
vendor
/
goldspecdigital
/
laravel-eloquent-uuid
/
src
/
Database
/
Eloquent
<?php declare(strict_types=1); namespace GoldSpecDigital\LaravelEloquentUUID\Database\Eloquent; use Exception; use Illuminate\Database\Eloquent\Model as BaseModel; use Ramsey\Uuid\Uuid; abstract class Model extends BaseModel { /** * The "type" of the auto-incrementing ID. * * @var string */ protected $keyType = 'string'; /** * Indicates if the IDs are UUIDs. * * @var bool */ protected $keyIsUuid = true; /** * The UUID version to use. * * @var int */ protected $uuidVersion = 4; /** * Indicates if the IDs are auto-incrementing. * * @var bool */ public $incrementing = false; /** * The attributes that are mass assignable. * * @var array */ protected $guarded = []; /** * The attributes that should be cast to native types. * * @var array */ protected $casts = [ 'created_at' => 'datetime', 'updated_at' => 'datetime', 'deleted_at' => 'datetime', ]; /** * The "booting" method of the model. */ protected static function boot(): void { parent::boot(); static::creating(function (self $model): void { // Automatically generate a UUID if using them, and not provided. if ($model->keyIsUuid && empty($model->{$model->getKeyName()})) { $model->{$model->getKeyName()} = $model->generateUuid(); } }); } /** * @throws \Exception * @return string */ protected function generateUuid(): string { switch ($this->uuidVersion) { case 1: return Uuid::uuid1()->toString(); case 4: return Uuid::uuid4()->toString(); } throw new Exception("UUID version [{$this->uuidVersion}] not supported."); } }
[+]
..
[-] Model.php
[edit]
[-] Uuid.php
[edit]