File: D:/HostingSpaces/SBogers68/ouddorp-duin.nl/app/Komma/Posts/PostController.php
<?php
/**
* Short description for the file.
*
* @author Komma <support@komma.pro>
* @copyright (c) 2012-2015, Komma Mediadesign
*/
namespace Komma\Posts;
use Komma\Blocks\BlockService;
use Komma\LanguageService;
use Komma\Pages\PageService;
class PostController extends \BaseController
{
public $data;
protected $pageService;
protected $blockService;
protected $postService;
public $languageService;
public function __construct(PageService $pageService, BlockService $blockService, PostService $postService, LanguageService $languageService)
{
parent::__construct();
$this->pageService = $pageService;
$this->blockService = $blockService;
$this->postService = $postService;
$this->languageService = $languageService;
}
// News overview page
public function index(){
//Check if language matches the url before loading content
$this->languageService->checkRouteWithSetLanguage();
//get content of page and get all page links
$page = $this->pageService->getPageByCodeName('news');
$links = $this->pageService->getAllRoutes();
//Get the blog items with pagination
$posts = $this->postService->getAllPosts(true);
$this->postService->makeCarbonDate($posts);
return \View::make('layouts.pages.posts.index')
->with('page', $page)
->with('links', $links)
->with('posts', $posts);
}
// News detail page
public function show($postId){
//Check if language matches the url before loading content
$this->languageService->checkRouteWithSetLanguage();
//Load post content and translation of this post
$page = $this->postService->getPost($postId);
$links = $this->pageService->getAllRoutes();
return \View::make('layouts.pages.posts.show')
->with('page', $page)
->with('links', $links);
}
}