<?php

namespace LaraBB\Settings\UI\Web\Handlers\Admin\Prefix;

use Illuminate\Http\RedirectResponse;
use LaraBB\Settings\Actions\Prefix\UpdateAction;
use LaraBB\Settings\UI\Web\Requests\Prefix\Update;

/**
 * Class UpdateHandler
 * @package LaraBB\Settings\UI\Web\Handlers\Admin\Prefix
 */
class UpdateHandler
{
    /**
     * UpdateHandler constructor.
     * @param UpdateAction $updateAction
     */
    public function __construct(private readonly UpdateAction $updateAction)
    {

    }

    /**
     * @param Update $request
     * @return RedirectResponse
     */
    public function __invoke(Update $request): RedirectResponse
    {
        return $this->updateAction->run($request) ? $request->success() : $request->failed();
    }
}
