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/farmfun/reserveren.farmfun.be/app/Komma/Posts/PostController.php
<?php

namespace App\Komma\Posts;

use App\Komma\Base\Controller;
use App\Komma\Components\ComponentService;
use App\Komma\Posts\Models\Post;

class PostController extends Controller
{
    /** @var PostService */
    private $postService;

    /** @var string */
    private $postPaginationKey = 'postPagination';

    public function __construct()
    {
        parent::__construct();
        $this->postService = app()->make(PostService::class);
    }

    /**
     * @return \Illuminate\Contracts\View\View
     */
    public function index()
    {
        // Get the post through the set links
        $page = $this->links->posts->node;

        $posts = $this->postService->getPostsPaginated();
        $posts->withPath($this->links->posts->route);

        $this->keepTrackOfPagination($this->postPaginationKey);

        // Make language menu for index page
//        $languageMenu = $this->pageService->makeLanguageSwitchForPage($this->links->posts, $this->links->home);

        // Return view
        return view('site.templates.posts_index', [
            'page' => $page,
            'links' => $this->links,
            'posts' => $posts,
            //            'languageMenu' => $languageMenu,
        ]);
    }

    /**
     * @param Post $post
     * @return \Illuminate\Contracts\View\View
     */
    public function show(Post $post)
    {
        $post->load('translation', 'images');

        if (! $post->active) {
            abort(404);
        }

        // Get the page through the set links
        $page = $this->links->posts->node;

        $componentService = app(ComponentService::class);
        $components = $componentService->getViewComponents($post->translation);

        // Create previous route for better navigation UX
        $previousRoute = $this->createPreviousRoute($this->postPaginationKey, $this->links->posts->route);

        $otherPosts = $this->postService->getNextPosts($post);

        // Make language menu for found index page
        $languageMenu = $this->pageService->makeLanguageSwitchForPage($this->links->posts);
//        $this->pageService->extendLanguageMenuWithResource($languageMenu, $post, $this->links->home);

        // Return view
        return view('site.templates.posts_show', [
            'page' => $page,
            'post' => $post,
            'otherModels' => $otherPosts,
            'components' => $components,
            'links' => $this->links,
            'previousRoute' => $previousRoute,
            'languageMenu' => $languageMenu,
        ]);
    }
}