<?php

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

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

/**
 * Class StoreHandler
 * @package LaraBB\Forum\UI\Web\Handlers\Admin
 */
class StoreHandler extends Controller
{
    /**
     * StoreHandler constructor.
     * @param StoreAction $storeAction
     */
    public function __construct(private readonly StoreAction $storeAction)
    {
    }

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