<?php

namespace LaraBB\Post\UI\Web\Handlers;

use App\Http\Controllers\Controller;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use LaraBB\Post\Actions\EditAction;
use LaraBB\Post\UI\Web\Requests\Edit;

/**
 * Class EditHandler
 * @package LaraBB\Post\UI\Web\Handlers
 */
class EditHandler extends Controller
{
    /**
     * EditHandler constructor.
     * @param EditAction $editAction
     * @param Factory $view
     */
    public function __construct(
        private readonly EditAction $editAction,
        private readonly Factory $view
    ) {

    }


    /**
     * @param Edit $request
     * @return View
     */
    public function __invoke(Edit $request): View
    {
        return $this->view->make('post::create-edit', array_merge(
            ['edit' => true],
            $this->editAction->run($request)
        ));
    }
}
