<?php

namespace LaraBB\Forum\UI\Web\Handlers;

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

/**
 * Class IndexHandler
 * @package LaraBB\Forum\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 Show $request
     * @param $slug
     * @return View
     */
    public function __invoke(Show $request, $slug): View
    {
        return $this->view->make('forum::index', $this->indexAction->run($request));
    }
}
