File: D:/HostingSpaces/fire-tech/fire-tech.nl/app/KommaApp/Course/Kms/CourseController.php
<?php
namespace App\KommaApp\Courses\Kms;
/**
* @author Komma <info@komma.pro>
* @copyright (c) 2012-2016, Komma
*/
use App\KommaApp\Kms\Core\SectionController;
use App\KommaApp\Kms\Core\Tree\TreeService;
use App\KommaApp\Courses\Models\Course;
class CourseController extends SectionController
{
protected $slug = "courses";
protected $forModelName = Course::class;
protected $treeService;
/**
* Constructor
* @param CourseSection $section
* @param TreeService $treeService
*/
public function __construct(CourseSection $section, TreeService $treeService)
{
parent::__construct($section);
$this->treeService = $treeService;
$this->treeService->setSectionService($this->section->getSectionService());
$this->treeService->setModel(new Course());
}
public function getCourseStructureAsJson($siteSlug)
{
$this->kms->setSite($siteSlug);
$tree = $this->treeService->getStructure();
return \Response::json($tree);
}
public function setCourseStructureAsJson($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);
}
}