<?php

namespace LaraBB\Category\UI\Web\Handlers;

use App\Http\Controllers\Controller;
use Illuminate\Contracts\View\View;
use Illuminate\View\Factory;
use LaraBB\Category\Actions\IndexAction;
use LaraBB\Category\UI\Web\Requests\Index;

/**
 * Class IndexHandler
 * @package LaraBB\Category\UI\Web\Handlers
 */
class IndexHandler extends Controller
{
    /**
     * IndexHandler constructor.
     * @param IndexAction $indexAction
     * @param Factory $view
     */
    public function __construct(
        private readonly IndexAction $indexAction,
        private readonly Factory $view
    ) {
    }

    /**
     * @param Index $request
     * @return View
     */
    public function __invoke(Index $request): View
    {
        return $this->view->make('category::index', $this->indexAction->run($request));
    }
}
