File: D:/HostingSpaces/SBogers10/rentman2019.komma.pro/app/Komma/Solutions/SolutionController.php
<?php
namespace App\Komma\Solutions;
use App\Http\Controllers\Controller;
use App\Komma\Components\ComponentService;
use App\Komma\Solutions\Models\Solution;
class SolutionController extends Controller
{
/**
* @return mixed
*/
public function index()
{
if (! isset($this->links->solutions)) {
abort(404);
}
// Get the page through the set links
$page = $this->links->solutions->node;
// Get all products
$solutions = $this->solutionService->getAllSolutions();
// Make language menu for index page
$languageMenu = $this->pageService->makeLanguageSwitchForPage($this->links->solutions, $this->links->home);
// Return view
return \View::make('site.templates.solutions_index', [
'page' => $page,
'links' => $this->links,
'solutions' => $solutions,
'languageMenu' => $languageMenu,
]);
}
/**
* @param Solution $solution
* @return \Illuminate\Contracts\View\View
*/
public function show(Solution $solution)
{
if (! isset($this->links->solutions)) {
abort(404);
}
$solution->load('translation', 'translations');
$enTranslation = $solution->translations->where('language_id', 40)->first();
if (! $enTranslation->active && $enTranslation->preview === 0) {
abort(404);
}
if (! $solution->translation->preview) {
$solution->setRelation('translation', $enTranslation);
}
// $this->checkIfModelShouldThrowAbort($solution);
$page = $this->links->solutions->node;
$componentService = \App::make(ComponentService::class);
$components = $componentService->getViewComponents($solution->translation);
// Make language menu for show page
$languageMenu = $this->pageService->makeLanguageSwitchForPage($this->links->solutions);
$this->pageService->extendLanguageMenuWithResource($languageMenu, $solution, $this->links->home);
// Return view
return \View::make('site.templates.solutions_show', [
'page' => $page,
'solution' => $solution,
'components' => $components,
'links' => $this->links,
'languageMenu' => $languageMenu,
'images' => $solution->languageImages(),
'alterHeadings' => true,
]);
}
}