File: D:/HostingSpaces/SBogers10/anvil.komma.pro/app/KommaApp/Specialisms/Kms/SpecialismController.php
<?php
namespace App\KommaApp\Specialisms\Kms;
/**
* @author Komma <info@komma.pro>
* @copyright (c) 2012-2016, Komma
*/
use App\KommaApp\Kms\Core\SiteSectionController;
use App\KommaApp\Kms\Core\Tree\TreeService;
use App\KommaApp\Specialisms\Models\Specialism;
class SpecialismController extends SiteSectionController
{
protected $slug = "specialisms";
protected $forModelName = Specialism::class;
protected $treeService;
/**
* Constructor
* @param SpecialismSection $section
* @param TreeService $treeService
*/
public function __construct(SpecialismSection $section, TreeService $treeService)
{
parent::__construct($section);
$this->treeService = $treeService;
$this->treeService->setSectionService($this->section->getSectionService());
$this->treeService->setModel(new Specialism());
}
public function getSpecialismStructureAsJson($siteSlug)
{
$this->kms->setSite($siteSlug);
$tree = $this->treeService->getStructure();
return \Response::json($tree);
}
public function setSpecialismStructureAsJson($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);
}
}