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/Integrations/IntegrationController.php
<?php

namespace App\Komma\Integrations;

use App\Http\Controllers\Controller;
use App\Komma\Components\ComponentService;
use App\Komma\Integrations\Models\Integration;

class IntegrationController extends Controller
{
    /**
     * @return \Illuminate\Contracts\View\View
     */
    public function index()
    {
        if (! isset($this->links->integrations)) {
            abort(404);
        }

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

        $integrations = $this->integrationService->getAllIntegrations();

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

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

    /**
     * @param Integration $integration
     * @return \Illuminate\Contracts\View\View
     */
    public function show(Integration $integration)
    {
        // Load the needed relations
        $integration->load('translation', 'translations', 'images');

        if (app()->getLocale() != 'en' && $integration->translation->populate_from_english) {
            $fallbackTranslation = $integration->translations->where('language_id', 40)->first();
            $integration->translation = $fallbackTranslation;
            $integration->used_fallback_translation = true;
        }

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

        $componentService = \App::make(ComponentService::class);
        $components = $componentService->getViewComponents($integration->translation);

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

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