<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class ContestAnswer extends Model
{
    protected $fillable = [
        'contest_participant_id',
        'contest_question_id',
        'answer_text',
        'is_correct',
        'taken_time',
        'score',
    ];

    protected $casts = [
        'taken_time' => 'integer',
        'is_correct' => 'boolean',
        'score' => 'decimal:2',
        'answer_text' => 'array',
    ];

    public function participant(): \Illuminate\Database\Eloquent\Relations\BelongsTo
    {
        return $this->belongsTo(ContestParticipant::class);
    }

    public function question(): \Illuminate\Database\Eloquent\Relations\BelongsTo
    {
        return $this->belongsTo(ContestQuestion::class);
    }

    public function contest(): \Illuminate\Database\Eloquent\Relations\BelongsTo
    {
        // return $this->belongsTo(Contest::class);
        return $this->belongsTo(Contest::class, 'contest_id');
    }
}
