52 lines
1.1 KiB
PHP
52 lines
1.1 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',
|
|
'unix_start_time',
|
|
'is_active',
|
|
'unix_end_time',
|
|
'screen_w',
|
|
'screen_h'
|
|
];
|
|
|
|
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';
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|