<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class QuestionnaireAnswer extends Model
{
    protected $fillable = [
        'questionnaire_response_id', 'questionnaire_question_id', 'answer_value',
    ];

    protected function casts(): array
    {
        return ['answer_value' => 'array'];
    }

    public function response()
    {
        return $this->belongsTo(QuestionnaireResponse::class, 'questionnaire_response_id');
    }

    public function question()
    {
        return $this->belongsTo(QuestionnaireQuestion::class, 'questionnaire_question_id');
    }
}
