File: D:/HostingSpaces/SBogers10/rentman2019.komma.pro/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,
]);
}
}