<?php

namespace LaraBB\Category\UI\Web\Handlers;

use App\Http\Controllers\Controller;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\View\Factory;
use LaraBB\Category\Actions\ShowAction;
use LaraBB\Category\UI\Web\Requests\Show;

/**
 * Class CategoryHandler
 * @package LaraBB\Category\UI\Web\Handlers
 */
class ShowHandler extends Controller
{
    /**
     * CategoryHandler constructor.
     * @param ShowAction $showAction
     * @param Factory $view
     */
    public function __construct(
        private readonly ShowAction $showAction,
        private readonly Factory $view
    ) {

    }

    /**
     * @param Show $request
     * @param $slug
     * @return View|RedirectResponse
     */
    public function __invoke(Show $request, $slug): View|RedirectResponse
    {
        return $this->view->make('category::show', $this->showAction->run($request));
    }
}
