HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/BDeurzen/vandeurzentuinontwerp.nl/app/Komma/Posts/PostController.php
<?php

/**
 * Short description for the file.
 *
 * @author      Tim Van Samang <timvansamang@komma.pro>
 * @copyright   (c) 2012-2015, Komma Mediadesign
 */

namespace Komma\Posts;

use Komma\Blocks\BlockService;
use Komma\Pages\PageService;

class PostController extends \BaseController
{

    public $data;
    protected $pageService;
    protected $blockService;
    protected $postService;

    public function __construct(PageService $pageService, BlockService $blockService, PostService $postService)
    {
        $this->pageService = $pageService;
        $this->blockService = $blockService;
        $this->postService = $postService;

        $this->data = (object)[];
    }

    //News index page
    public function index(){

        $page = $this->pageService->getPageByCodeName('services');

        $this->data->content = $page;
        $this->data->id = $this->data->content->id;
        $this->data->content->meta_title = $page->translation->meta_title;
        $this->data->content->meta_description = $page->translation->meta_description;

        $blocks = $page->blocks->keyBy('code_name');

        $posts = $this->postService->getAllPosts();

        return \View::make('posts.overview')
            ->with('data', $this->data)
            ->with('blocks', $blocks)
            ->with('posts', $posts);
    }

    public function show($postId){

        $page = $this->pageService->getPageByCodeName('services');
        $post = $this->postService->getPost($postId);

        $this->data->content = $post;

        $this->data->content->translation->description = json_decode($this->data->content->translation->description);
        //Add the meta data to data->content
        $this->data->content->meta_title = $post->translation->meta_title;
        $this->data->content->meta_description = $post->translation->meta_description;

        $blocks = $page->blocks->keyBy('code_name');

        $posts = $this->postService->getAllPosts();

        return \View::make('posts.postDetail')
            ->with('blocks', $blocks)
            ->with('posts', $posts)
            ->with('data', $this->data)->render();

    }

}