<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class QuestionBankQuestion extends Model
{
    protected $fillable = [
        'section_id',
        'parent_question_id',
        'condition_value',
        'display_order',
        'question_text',
        'question_type',
        'options',
        'required',
        'order'
    ];

    protected $casts = [
        'options' => 'array',
        'required' => 'boolean',
    ];

    public function section()
    {
        return $this->belongsTo(QuestionBankSection::class, 'section_id');
    }

    public function parentQuestion()
    {
        return $this->belongsTo(QuestionBankQuestion::class, 'parent_question_id');
    }

    public function childQuestions()
    {
        return $this->hasMany(QuestionBankQuestion::class, 'parent_question_id');
    }
}
