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/SBogers95/rentman.io/app/Komma/CustomerStories/CustomerStoryController.php
<?php

namespace App\Komma\CustomerStories;

use App\Http\Controllers\Controller;
use App\Komma\Components\ComponentService;
use App\Komma\CustomerStories\Models\CustomerStory;

class CustomerStoryController extends Controller
{
    protected $customerStoryService;

    private $customerStoriesPaginationKey = 'customerStoriesPagination';

    public function __construct()
    {
        parent::__construct();
        $this->customerStoryService = \App::make(CustomerStoryService::class);
    }

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

        $customerStories = $this->customerStoryService->getAllCustomerStories(true);
        $customerStories->withPath('/'.$this->links->customerStories->route);

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

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

        // Return view
        return \View::make('site.templates.customerStories_index', [
            'page' => $page,
            'links' => $this->links,
            'customerStories' => $customerStories,
            'languageMenu' => $languageMenu,
        ]);
    }

    /**
     * @param CustomerStory $customerStory
     * @return \Illuminate\Contracts\View\View
     * @throws \ReflectionException
     */
    public function show(CustomerStory $customerStory)
    {
        $customerStory->load('logo', 'impression', 'products', 'products.translation', 'translation', 'translations', 'translation.componentAreas');

        $this->checkIfModelShouldThrowAbort($customerStory);

        $page = $this->links->customerStories->node;

        /** @var $componentService ComponentService */
        $componentService = \App::make(ComponentService::class);
        $components = $componentService->getViewComponents($customerStory->translation);

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

        // Make language menu for given customerStory
        $languageMenu = $this->pageService->makeLanguageSwitchForPage($this->links->customerStories);
        $this->pageService->extendLanguageMenuWithResource($languageMenu, $customerStory, $this->links->home);
//        $this->customerStoryService->extendLanguageMenuWithResource($languageMenu, $customerStory, $this->links->home);

        // Get the more customer stories
        $otherCustomerStories = $this->customerStoryService->getMoreCustomerStories($customerStory);

        return \View::make('site.templates.customerStories_show', [
            'page' => $page,
            'customerStory' => $customerStory,
            'components' => $components,
            'links' => $this->links,
            'previousRoute' => $previousRoute,
            'languageMenu' => $languageMenu,
            'otherCustomerStories' => $otherCustomerStories,
        ]);
    }
}