File: D:/HostingSpaces/SBogers10/umans.komma.pro/app/Komma/Pages/PageController.php
<?php
namespace Komma\Pages;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redirect;
use Komma\BaseController;
use Komma\Blocks\BlockService;
use Komma\Contact\ContactController;
use Komma\LanguageService;
use Komma\Sitemap\SitemapController;
class PageController extends \BaseController
{
protected $pageService;
protected $blockService;
protected $contactController;
protected $sitemapController;
public $languageService;
public function __construct(PageService $pageService, BlockService $blockService, ContactController $contactController, SitemapController $sitemapController, LanguageService $languageService)
{
parent::__construct();
$this->pageService = $pageService;
$this->blockService = $blockService;
$this->contactController = $contactController;
$this->sitemapController = $sitemapController;
$this->languageService = $languageService;
}
public function show($id = 2)
{
//Check if language matches the url before loading the content
$this->languageService->checkRouteWithSetLanguage();
//get content of page
$page = $this->pageService->getPageContent($id);
//Check if needed to send to other location/controller
if($page->code_name == 'sitemap') return $this->sitemapController->showSitemap($page);
if($page->code_name == 'offer') return $this->contactController->offerForm($page);
if($page->code_name == 'contact') return $this->contactController->contactForm($page);
//get all page links
$links = $this->pageService->getAllRoutes();
//View is code name unless in array to make them default pages
$view = $page->code_name;
if(in_array($view, ['pricing', 'other_default'])) $view = 'page';
if($page->code_name != 'home')
{
$pagesWithSubMenu = ['pvc_windows', 'pvc_doors', 'aluminium_windows', 'aluminium_doors', 'isolation', 'isolationpearls'];
$parent = $page->getParent();
$page->parent = (object)[
'code_name' => $parent->code_name,
'name' => $parent->translation->name
];
if(in_array($page->code_name, $pagesWithSubMenu))
{
$view = 'informationProducts';
$page->doorsWindowsPage = true;
$page->islationPage = true;
$page->subMenu = $this->pageService->getPagesByTree(($page->lft - 1), $page->rgt);
}
if(in_array($parent->code_name, $pagesWithSubMenu))
{
$view = 'informationProducts';
$page->doorsWindowsPage = true;
$page->islationPage = true;
$page->parentPage = $parent->code_name;
if($page->code_name != 'isolationpearls') $page->subMenu = $this->pageService->getPagesByTree(($parent->lft - 1), $parent->rgt);
else $page->subMenu = $this->pageService->getPagesByTree(($page->lft - 1), $page->rgt);
}
}
if($page->code_name == 'isolation_placing') $view = 'isolationPlacing';
if($page->code_name == 'windows-doors') $view = 'windowsDoors';
return \View::make('layouts.pages.' . $view)
->with('page', $page)
->with('links', $links);
}
}