<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Questions extends Model
{
    protected $table = 'questions';
    
    public $timestamps = true;
    
    protected $fillable = ['name','complain_type_id','category_id','question_option_id','status','added_by_id','sort_order','department_id'];

    public function getQuestionOptions($questionId)
    {
    	return QuestionOptions::where('question_id', $questionId)
    	                      ->orderBy('sort_order', 'ASC')
    	                      ->get();
    }

    public function getQuestionByParentQuestionOption($questionId, $questionOptionId)
    {
    	return $this->where('parent_question_id', $questionId)
    		   		->where('question_option_id', $questionOptionId)
    		   		->first();
    }
}