<?php

namespace App\Models;

use CodeIgniter\Model;

class RespuestaModel extends Model
{
    protected $table = 'answers';
    protected $primaryKey = 'id';
    protected $useTimestamps = true;

    protected $allowedFields = ['survey_id', 'user_id', 'answer', 'question_id'];

    protected $validationRules = [
        'survey_id' => 'required',
        'user_id' => 'required',
        'answer' => 'required',
        'question_id' => 'required',
    ];

    public function getRespuestas($survey_id, $user_id)
    {
        return $this
            ->where(['survey_id' => $survey_id, 'user_id' => $user_id])
            ->findAll();
    }
}
