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/stafa.komma.pro/app/Komma/Pages/PageController.php
<?php

namespace App\Komma\Pages;

use App\Komma\Base\Controller;
use App\Komma\Buttons\Models\Button;
use App\Komma\Components\ComponentService;
use App\Komma\Pages\Models\Page;
use App\Komma\Projects\ProjectService;
use App\Komma\Servicepoints\Models\Servicepoint;

final class PageController extends Controller
{
    private $projectService;

    public function __construct()
    {
        parent::__construct();
        $this->projectService = app(ProjectService::class);
    }

    /**
     * @param Page $page
     * @return \Illuminate\Contracts\View\View
     */
    public function show(Page $page)
    {
//        Uncomment this line to test the under construction page
//        return view('site.templates.underConstruction');

        // Get the page through the set links if translation isnt defined
        if(!isset($page->translation)) $page = $this->links->{$page->code_name}->node;

        // By default get the first servicepoint
        $servicepoint = Servicepoint::first();

        // Get the chosen servicepoint for the page
        if(!empty($page->translation->servicepoint_id)) $servicepoint = Servicepoint::find($page->translation->servicepoint_id);

        $heroButton = null;
        if(!empty($page->translation->hero_button_id)) $heroButton = Button::where('id', $page->translation->hero_button_id)->with('translation')->first();

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

        $featuredProjects = $this->projectService->getFeaturedProjects()->get();

        $children = $page->findChildren();

        // Make language menu for given page
        $languageMenu = $this->pageService->makeLanguageSwitchForPage($this->links->{$page->code_name}, $this->links->home);

        $view = 'site.templates.' . $page->code_name;
        if( ! view()->exists($view)) $view = 'site.templates.default';

        // Return view
        return view($view,[
            'components' => $components,
            'links' => $this->links,
            'languageMenu' => $languageMenu,
            'page' => $page,
            'children' => $children,
            'featuredProjects' => $featuredProjects,
            'servicepoint' => $servicepoint,
            'heroButton' => !empty($heroButton) ? $heroButton : null,
        ]);
    }

    public function offline()
    {
        return view('site.templates.offline');
    }
}