<?php

namespace App\Models;

use CodeIgniter\Model;

class PreguntaModel extends Model
{
    protected $table = 'questions';
    protected $primaryKey = 'id';
    protected $useTimestamps = true;

    protected $allowedFields = ['question', 'frm_option', 'type', 'order_by', 'survey_id'];

    protected $validationRules = [
        'question' => 'required',
        'survey_id' => 'required',
        'type' => 'required',
    ];

    public function getPreguntas($encuestaId)
    {
        return $this
            ->where('survey_id', $encuestaId)
            ->findAll();
    }
}
