<?php

namespace LaraBB\Group\UI\Web\Handlers\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use LaraBB\Group\Actions\Admin\UpdateAction;
use LaraBB\Group\UI\Web\Requests\Update;

/**
 * Class UpdateHandler
 * @package LaraBB\User\UI\Web\Handlers\Admin
 */
class UpdateHandler extends Controller
{

    /**
     * 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();
    }
}
