<?php
/**********************************************************************
 * ProxmoxVPS developed. (26.03.19)
 * *
 *
 *  CREATED BY MODULESGARDEN       ->       http://modulesgarden.com
 *  CONTACT                        ->       contact@modulesgarden.com
 *
 *
 * This software is furnished under a license and may be used and copied
 * only  in  accordance  with  the  terms  of such  license and with the
 * inclusion of the above copyright notice.  This software  or any other
 * copies thereof may not be provided or otherwise made available to any
 * other person.  No title to and  ownership of the  software is  hereby
 * transferred.
 *
 *
 **********************************************************************/

namespace ModulesGarden\Servers\ProxmoxVps\App\Http\Admin;

use ModulesGarden\ProxmoxAddon\App\Services\Vps\ProductService;
use ModulesGarden\Servers\ProxmoxVps\App\UI\Admin\Product\Forms\MainForm;
use ModulesGarden\Servers\ProxmoxVps\App\UI\Admin\Product\Pages\CustomOptionsWidget;
use ModulesGarden\Servers\ProxmoxVps\App\UI\Admin\Product\Pages\MainContainer;
use ModulesGarden\Servers\ProxmoxVps\Core\UI\Traits\RequestObjectHandler;
use ModulesGarden\Servers\ProxmoxVps\Core\UI\Traits\WhmcsParams;
use ModulesGarden\Servers\ProxmoxVps\Packages\WhmcsService\UI\ConfigurableOption\OptionsWidget;
use function ModulesGarden\Servers\ProxmoxVps\Core\Helper\sl;
use function ModulesGarden\Servers\ProxmoxVps\Core\Helper\viewIntegrationAddon;


class Product
{
    use RequestObjectHandler;
    use WhmcsParams;
    use ProductService;

    public function index()
    {

        $productId = $this->getRequestValue("id");
        $product   = \ModulesGarden\ProxmoxAddon\App\Models\Whmcs\Product::where("id", $productId)->firstOrFail();
        sl("whmcsParams")->setParams($product->getParams());

        header("HTTP/1.1 200 OK");
        return viewIntegrationAddon()
            ->addElement(MainForm::class)
            ->addElement(new  OptionsWidget());

    }

}
