43 lines
910 B
PHP
43 lines
910 B
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'
|
|
];
|
|
|
|
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);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|