File: D:/HostingSpaces/SBogers26/gripp.nu/app/Komma/Pages/PageController.php
<?php
namespace Komma\Pages;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Komma\Posts\PostService;
class PageController extends \BaseController
{
public $data;
protected $pageService;
protected $postService;
public function __construct(PageService $pageService, PostService $postService){;
$this->pageService = $pageService;
$this->postService = $postService;
$this->data = (object)[];
}
public function show($id = 2)
{
$this->data->id = $id;
$page = $this->pageService->getPageContent($id);
$this->data->content = $page;
if ($page->code_name == 'home') return $this->home();
if ($page->code_name == 'av') return $this->av();
$view = 'page';
$viewData = ['data'=> $this->data];
if(!empty($page->translation->description)) {
$viewData['dynamicBlocks'] = json_decode($page->translation->description);
}
return \View::make('layouts.pages.' .$view)
->with($viewData);
}
public function index($page = null)
{
if (!$page) $page = $this->pageService->getPageByCodeName('home');
$this->data->content = $page;
$this->data->id = $this->data->content->id;
return \View::make('layouts.pages.' . $this->data->content->code_name)
->with('data', $this->data);
}
public function home(){
$this->data->meta_title = 'Gripp Energiebeheer';
$this->data->meta_description = 'Gripp adviseert je bij het maken én uitvoeren van een sterk energiebeheerplan. Makkelijk en zonder gedoe.';
return \View::make('layouts.pages.home')
->with('data', $this->data)
->with('news', $this->postService->getHomePost());
}
public function av(){
$this->data->meta_title = 'Gripp Energiebeheer';
$this->data->meta_description = 'Gripp adviseert je bij het maken én uitvoeren van een sterk energiebeheerplan. ';
return \View::make('layouts.pages.av')->with('data', $this->data);
}
}