<?php

namespace App\Exports;

use App\Exports\Sheets\FormAnswerSheet;
use App\Models\Fpdx\FormQuestionModel;
use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\WithMultipleSheets;

class FormExport implements WithMultipleSheets
{
    use Exportable;


    private $formId;

    public function __construct($formId)
    {
        $this->formId = $formId;
    }


    public function sheets(): array
    {
        $sheets = [];
        $questions = FormQuestionModel::where('form_id', $this->formId)->get();

        foreach ($questions as $question) {
            $sheets[] = new FormAnswerSheet($question);
        }

        return $sheets;
    }
}
