Files
go-no-go/app/Models/Session.php
2026-02-03 20:18:08 +01:00

88 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
final class Session extends Model
{
use HasFactory;
protected $table = 'questionnaire_sessions';
/**
* Fillable attributes for mass assignment.
*/
protected $fillable = [
'user_id',
'category_id',
'screening_id',
'status',
'score',
'result',
'basic_info',
'additional_comments',
'completed_at',
];
/**
* Cast attributes to specific types.
*/
protected function casts(): array
{
return [
'user_id' => 'integer',
'category_id' => 'integer',
'screening_id' => 'integer',
'score' => 'integer',
'basic_info' => 'array',
'completed_at' => 'datetime',
];
}
/**
* Get the user that owns this session.
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/**
* Get the category for this session.
*/
public function category(): BelongsTo
{
return $this->belongsTo(Category::class);
}
/**
* Get the screening that preceded this session.
*/
public function screening(): BelongsTo
{
return $this->belongsTo(Screening::class);
}
/**
* Get all answers for this session.
*/
public function answers(): HasMany
{
return $this->hasMany(Answer::class);
}
/**
* Get all logs for this session.
*/
public function logs(): HasMany
{
return $this->hasMany(Log::class);
}
}