File: D:/HostingSpaces/SBogers10/zuiderbos.komma.pro/app/Komma/Brochures/BrochureController.php
<?php
/**
* Short description for the file.
*
* @author Komma <support@komma.pro>
* @copyright (c) 2012-2015, Komma Mediadesign
*/
namespace Komma\Brochures;
use Komma\Kms\Schools\School;
use Komma\LanguageService;
use Komma\Pages\PageService;
class BrochureController extends \BaseController
{
public $data;
protected $pageService;
protected $brochureService;
public $languageService;
public function __construct(PageService $pageService, LanguageService $languageService, BrochureService $brochureService)
{
parent::__construct();
$this->pageService = $pageService;
$this->brochureService = $brochureService;
$this->languageService = $languageService;
}
//Overview page
public function index($page = null)
{
if ($page == null) {
//Check if language matches the url before loading the content
$this->languageService->checkRouteWithSetLanguage();
//get content of page by route because of the multiple news overviews all page links
$page = $this->pageService->getPageByRoute(\Request::path());
// Get root parent and append code_name to page
// So we can find out to which branch/school the page belongs
if ($page->getDepth() != 1) {
$page->root = $this->pageService->getRootParent($page);
} else {
// The page itself is the root branch, so to prevent writing if/else statements append it as branch
$page->root = $page;
}
// Load school to page
$page->school = School::where('type', $page->root->code_name)->first();
}
$links = $this->pageService->getAllRoutes();
$brochures = $this->brochureService->getAllBrochures();
return \View::make('layouts.pages.brochures.index')
->with('brochures', $brochures)
->with('page', $page)
->with('links', $links);
}
public function getAllBrochures()
{
return $this->brochureService->getAllBrochures();
}
}