<?php

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

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

/**
 * Class UpdateHandler
 * @package LaraBB\Forum\UI\Web\Handlers\Admin
 */
class UpdateHandler extends Controller
{
    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();
    }
}
