HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/centrum8a/centrum8a.com/app/KommaApp/Shop/Categories/Kms/CategoryController.php
<?php

namespace App\KommaApp\Shop\Categories\Kms;

/**
 * @author      Komma <info@komma.pro>
 * @copyright   (c) 2012-2016, Komma
 */

use App\KommaApp\Kms\Core\Kms;
use App\KommaApp\Kms\Core\SectionController;
use App\KommaApp\Kms\Core\SiteSectionController;
use App\KommaApp\Kms\Core\Tree\TreeService;
use App\KommaApp\Shop\Categories\Models\Category;

class CategoryController extends SectionController
{
    protected $slug = "categories";
    protected $forModelName = Category::class;

    protected $treeService;

    /**
     * Constructor
     * @param Kms $kms
     * @param CategorySection $section
     * @param TreeService $treeService
     */
    public function __construct(CategorySection $section, TreeService $treeService)
    {
        parent::__construct($section);

        $this->treeService = $treeService;
        $this->treeService->setSectionService($this->section->getSectionService());
        $this->treeService->setModel(new Category());
    }

    public function getCategoryStructureAsJson()
//    public function getCategoryStructureAsJson($siteSlug)
    {
//        $this->kms->setSite($siteSlug);
        $tree = $this->treeService->getStructure();
        return \Response::json($tree);
    }

//    public function setCategoryStructureAsJson($siteSlug)
    public function setCategoryStructureAsJson()
    {
//        $this->kms->setSite($siteSlug);
        // Special way to get POST data send by ajax on IIS servers
        $data = json_decode(\Request::instance()->getContent());
        $tree = json_decode($data->tree);

        $tree = $this->treeService->setStructureWithJson($tree);

        return \Response::json($tree);
    }

}