47 lines
1005 B
PHP
47 lines
1005 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class TobiiDataModel extends Model
|
|
{
|
|
protected $table = 'tobii_data';
|
|
|
|
protected $primaryKey = 'id_tobii_data';
|
|
|
|
protected $keyType = 'string';
|
|
|
|
public $incrementing = false;
|
|
|
|
protected $fillable = [
|
|
'id_tobii_data',
|
|
'gaze_x',
|
|
'gaze_y',
|
|
'timestamp',
|
|
'id_test_sessions',
|
|
'is_valid',
|
|
];
|
|
|
|
protected $casts = [
|
|
'id_tobii_data' => 'string',
|
|
'gaze_x' => 'float',
|
|
'gaze_y' => 'float',
|
|
'timestamp' => 'datetime',
|
|
'id_test_sessions' => 'string',
|
|
];
|
|
|
|
protected static function boot()
|
|
{
|
|
parent::boot();
|
|
static::creating(function ($model) {
|
|
if (empty($model->id_tobii_data)) {
|
|
$model->id_tobii_data = (string) \Illuminate\Support\Str::uuid();
|
|
}
|
|
if (empty($model->is_valid)) {
|
|
$model->is_valid = '0';
|
|
}
|
|
});
|
|
}
|
|
}
|