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/SBogers10/rentman.komma.pro/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;

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

    //News index page
    public function index(){


        $this->languageService->checkRouteWithSetLanguage();
        $page = $this->pageService->getPageByCodeName('blog');

        $this->data->content = $page;
        $this->data->id = $this->data->content->id;
        $this->data->links = $this->pageService->getAllRoutes();
        $otherLanguages = $this->pageService->getOtherLanguageRoutes($this->data->id);

        $posts = $this->postService->getAllPosts();
        //dde($posts);
        if(sizeof($posts) > 10){
            if(is_array($posts)){
                $posts = array_slice($posts,0,10);
            }
            else{
                $posts = $posts->take(10);
            }
        }

        $postOverview = $this->postService->getAllPosts(true);
        //dde($posts);
        $this->postService->makeCarbonDate($posts);
        $this->postService->makeCarbonDate($postOverview);

        return \View::make('layouts.pages.postOverview')
            ->with('data', $this->data)
            ->with('blocks', $page->blocks)
            ->with('otherLanguages', $otherLanguages->allTranslations)
            ->with('blogItems', $posts)
            ->with('blogItemsOverview', $postOverview);

    }

    public function show($postId){

        $this->languageService->checkRouteWithSetLanguage();
        $this->data = $this->postService->getPost($postId);
        $this->data->links = $this->pageService->getAllRoutes();
        if(isset($this->data->translation->description) && $this->data->translation->description != '[]') $this->data->translation->description = json_decode($this->data->translation->description);
        $this->data->content = (object)['code_name' => $this->data->code_name];

        if(!$this->data->translation->active && !$this->data->translation->preview) \App::abort(404);

        $posts = $this->postService->getAllPosts();
        if(sizeof($posts) > 10){
            if(is_array($posts)){
                $posts = array_slice($posts,0,10);
            }
            else{
                $posts = $posts->take(10);
            }
        }
        $this->postService->makeCarbonDate($posts);

        $otherLanguages = $this->postService->getOtherLanguageRoutes($this->data->id);

        $featurePage = $this->pageService->getPageByCodeName('blog');
        $this->data->meta_title = $this->data->translation->title.' | '.$featurePage->translation->meta_title;
        $this->data->meta_description = strip_tags($this->data->translation->meta_description);

        return \View::make('layouts.pages.postDetail')
            ->with('blogItems', $posts)
            ->with('otherLanguages', $otherLanguages->allTranslations)
            ->with('data', $this->data)->render();
    }

}