<?php

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

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

/**
 * Class StoreHandler
 * @package LaraBB\User\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();
    }
}
