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/SBogers93/fitale.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 Carbon\Carbon;
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('news');

        $this->data->content = $page;
        $this->data->id = $this->data->content->id;

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

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

    }

    public function show($postId){

        $this->data = $this->postService->getPost($postId);

        $date = $this->data->date;
        $this->data->date = Carbon::createFromFormat('Y-m-d H:i:s',$date);

        $this->data->links = $this->pageService->getUrl();



        $posts = $this->postService->getAllExcept($postId);

        $this->postService->makeCarbonDate($posts);

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

    }

}