<?php

namespace App\Http\Controllers\Owner\{{ module }};

use App\Http\Controllers\Controller;
use App\Http\Controllers\Owner\c_Admin_Session;
use App\Http\Controllers\Owner\{{ module }}\Dto\{{ module }}UpdateDTO;
use App\Http\Helpers\ResponseBuilder;
use App\Modules\{{ module }}\Application\Update\Update{{ module }}Command;
use App\Modules\Shared\Domain\Bus\Command\CommandBus;
use App\Modules\Shared\Validator\Infraestructure\LaravelDTOGenerator;
use Illuminate\Http\Request;

final class {{ module }}UpdateController extends Controller
{
    private $domain;

    public function __construct(
        private CommandBus $commandBus,
        private LaravelDTOGenerator $dtoGenerator,
    ) {
        $this->domain = '{{ module }}';
    }

    public function __invoke(Request $request)
    {
        /** @var {{ module }}UpdateDTO $dto */
        $dto = $this->dtoGenerator->generate($request->all(), $this->domain, {{ module }}UpdateDTO::class);
        $adminSession = c_Admin_Session::check($request);

        $this->commandBus->dispatch(new Update{{ module }}Command(
{{ cmdArgs }}
        ));

        return ResponseBuilder::generate([], Responses{{ module }}::RESPONSE_UPDATE, $this->domain);
    }
}
