<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;
use App\Models\QAQuestions;

class HelpMenuQuestionnaireAnswersResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        $question = QAQuestions::where('id', $this->question_id)->first();
        return [
            'question_text' => $question ? $question->question_text : null,
            'free_text_answer' => $this->free_text_answer
        ];
    }
}
