File: D:/HostingSpaces/SBogers93/fitale.nl/app/Komma/Pages/PageController.php
<?php
namespace Komma\Pages;
use Illuminate\Http\Request;
use Komma\BaseController;
use Komma\Blocks\BlockService;
use Komma\Contact\ContactController;
class PageController extends \BaseController
{
public $data;
protected $pageService;
protected $blockService;
protected $contactController;
public function __construct(PageService $pageService, BlockService $blockService, ContactController $contactController)
{
$this->pageService = $pageService;
$this->blockService = $blockService;
$this->contactController = $contactController;
$this->data = (object)[];
}
public function show($id = 2)
{
$this->data->id = $id;
$page = $this->pageService->getPageContent($id);
$this->data->content = $page;
$this->data->links = $this->pageService->getUrl();
//dd('hoi');
if ($page->code_name == 'home') return $this->index($page);
if ($page->code_name == 'contact') return $this->contactController->contactForm();
$view = 'page';
return \View::make('layouts.pages.' .$view)
->with('blocks', $page->blocks)
->with('data', $this->data);
}
public function index($page = null)
{
if (!$page) $page = $this->pageService->getPageByCodeName('home');
$this->data->content = $page;
$this->data->id = $this->data->content->id;
$this->data->links = $this->pageService->getUrl();
return \View::make('layouts.pages.' . $this->data->content->code_name)
->with('data', $this->data)
->with('blocks', $page->blocks);
}
public function contact(){
dd('tet');
}
}