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/zuiderbos.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\Kms\Schools\School;
use Komma\LanguageService;
use Komma\Newsletters\Models\Newsletter;
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;
    }

    //Overview page
    public function index($page = null)
    {
        if ($page == null) {
            dd('shoulnd be in here anyway');
            //Check if language matches the url before loading content
            $this->languageService->checkRouteWithSetLanguage();

            //get content of page by route because of the multiple news overviews all page links
            $page = $this->pageService->getPageByRoute(\Request::path());
        }

        $news = $this->postService->customPaginator($page->getNews());

        $links = $this->pageService->getAllRoutes();

        return \View::make('layouts.pages.posts.index')
            ->with('page', $page)
            ->with('news', $news)
            ->with('links', $links);
    }

    public function show($postId)
    {
        //Check if language matches the url before loading content
        $this->languageService->checkRouteWithSetLanguage();

        //Load post content and translation of this post
        $post = $this->postService->getPost($postId);
        $links = $this->pageService->getAllRoutes();

        // Get Page by route because we can't use the rest_root 'news' to get it
        // This is because there are multiple news overviews
        $segments = \Request::segments();
        $parentRoute = '';
        for ($i = 0; $i <= (count($segments) - 2); $i++) {
            $parentRoute .= $segments[$i].'/';
        }
        $parentRoute = rtrim($parentRoute, '/');

        $page = $this->pageService->getPageByRoute($parentRoute);
        $page->root = $this->pageService->getRootParent($page);
        $page->school = School::where('type', $page->root->code_name)->first();

        $moreNews = $this->postService->getMoreNews($post, $page->getNews());

        return \View::make('layouts.pages.posts.show')
            ->with('page', $page)
            ->with('post', $post)
            ->with('moreNews', $moreNews)
            ->with('links', $links);
    }

    public function newsletter($postId)
    {
        //Check if language matches the url before loading content
        $this->languageService->checkRouteWithSetLanguage();

        //Load post content and translation of this post
//        $post = $this->postService->getPost($postId);

        $post = Newsletter::where('id', $postId)->first();

        $links = $this->pageService->getAllRoutes();

        // Get Page by route because we can't use the rest_root 'news' to get it
        // This is because there are multiple news overviews
        $segments = \Request::segments();
        $parentRoute = '';
        for ($i = 0; $i <= (count($segments) - 2); $i++) {
            $parentRoute .= $segments[$i].'/';
        }
        $parentRoute = rtrim($parentRoute, '/');

        $page = $this->pageService->getPageByRoute($parentRoute);
        $page->root = $this->pageService->getRootParent($page);
        $page->school = School::where('type', $page->root->code_name)->first();

        $moreNews = $this->postService->getMoreNews($post, $page->getNews());

        return \View::make('layouts.pages.posts.newsletter')
            ->with('page', $page)
            ->with('post', $post)
            ->with('moreNews', $moreNews)
            ->with('links', $links);
    }
}