File: D:/HostingSpaces/SBogers10/edwingovers.komma.pro/app/KommaApp/Shop/Discounts/DiscountController.php
<?php
namespace App\KommaApp\Shop\Discounts;
/**
* @author Komma <info@komma.pro>
* @copyright (c) 2012-2016, Komma
*/
use App\KommaApp\Kms\Core\SectionController;
use App\KommaApp\Kms\Core\Tree\TreeService;
class DiscountController extends SectionController
{
protected $slug = "discounts";
protected $forModelName = Discount::class;
protected $treeService;
/**
* Constructor
* @param DiscountSection $section
* @param TreeService $treeService
*/
public function __construct(DiscountSection $section, TreeService $treeService)
{
parent::__construct($section);
$this->treeService = $treeService;
$this->treeService->setSectionService($this->section->getSectionService());
$this->treeService->setModel(new Discount());
}
public function getPageStructureAsJson($siteSlug)
{
$this->kms->setSite($siteSlug);
$tree = $this->treeService->getStructure();
return \Response::json($tree);
}
public function setPageStructureAsJson($siteSlug)
{
$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);
}
}