<?php

namespace App\Services\Forms\Feedback;

use App\Events\FeedbackSender;
use App\Models\Objects\NirObject;
use App\Services\Forms\FormsService;

class FeedbackForms extends FormsService {
    public array $formTitles = ['create' => 'Создание операции', 'update' => 'Редактирование операции'];

    public function form(?string $id = null, array $data = []): array {
        $model = NirObject::byUuid($id)->first();
        $groups = [
            ['name' => 'common', 'fields' => $this->commonGroupFields($model)]
        ];
        return ['title' => $this->formTitle($model), 'data' => $groups];
    }

    public function commonGroupFields(?NirObject $model): array {
        return [];
    }


    public function store(array $data) {
        event(new FeedbackSender($data['mailto'], $data));
        return null;
    }

    public function update(string $id, array $data) {
        return null;
    }
}
