MIF_E31231392/app/Models/TestSessionsModel.php

48 lines
1.0 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class TestSessionsModel extends Model
{
protected $table = 'test_sessions';
protected $primaryKey = 'id_test_sessions';
protected $keyType = 'string';
public $incrementing = false;
protected $fillable = [
'status_session',
'token_session',
'id_booking',
'is_active',
];
protected $casts = [
'id_test_sessions' => 'string',
'id_booking' => 'string',
];
protected static function boot()
{
parent::boot();
static::creating(function ($model) {
if (empty($model->id_test_sessions)) {
$model->id_test_sessions = (string) \Illuminate\Support\Str::uuid();
}
if (empty($model->token_session)) {
$model->token_session = \Illuminate\Support\Str::random(50);
}
if (empty($model->is_active)) {
$model->is_active = '0';
}
});
}
}