<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class ProfileSubQuestion extends Model
{
    use HasFactory;
    protected $fillable = ['category_id', 'question_id', 'question', 'parent_sub_question_id', 'sub_question_type', 'sub_question_options'];
    public function getSubQuestionOptionsAttribute($value)
    {

        return unserialize($value);
    }

    public function subQuestions()
    {
        return $this->hasMany(ProfileSubQuestion::class, 'parent_sub_question_id', 'id');
    }

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