File: D:/HostingSpaces/Lacom/lacom.nl/app/KommaApp/Specialisms/SpecialismController.php
<?php
namespace App\KommaApp\Specialisms;
use App\Http\Controllers\Controller;
use App\KommaApp\Specialisms\Models\Specialism;
class SpecialismController extends Controller
{
private $specialismPrefix = 'pages.specialisms.';
protected $specialismService;
public function __construct(SpecialismService $specialismService)
{
parent::__construct();
$this->specialismService = $specialismService;
}
/**
* @param Specialism $specialism
* @return \Illuminate\Contracts\View\View
*/
public function show(Specialism $specialism)
{
// Load translation by eager loading
$specialism->load( 'translation');
// Get overview page
$page = $this->pageService->getPageByCodeName('specialisms');
$page->translation = $this->decodeDynamicContent( $page->translation );
// Generate page breadcrumb
$this->pageService->generateBreadcrumbTree($page, $this->links);
// Expend breadcrumb with the current specialism
$this->specialismService->expandBreadCrumbTree($page, $specialism, $this->links);
// Check if given Specialism belongs to the set site
if($specialism->site_id != \App::getSite()->id) throw abort(404);
// Get the route in other languages for menu and meta title
// TODO build service for generating the other language routes
// $otherLanguageRoutes = $this->languageService->getOtherLanguagesRoutes($specialism);
$page->preventFooterActive = true;
$specialisms = $this->specialismService->getAllSpecialisms();
// Determine the specialisms for the after content menu
$this->specialismService->makeNextSpecialisms($specialism, $specialisms);
// Determine the reference used on the page because we always want one
$this->referenceService->determineReferenceAndShareWithViews($specialism);
// Return view
return \View::make($this->baseViewPath.$this->specialismPrefix. 'show',[
'page' => $page,
'specialism' => $specialism,
'links' => $this->links,
'menuSpecialisms' => $specialisms,
// 'otherLanguages' => $otherLanguageRoutes,
]);
}
public function index(){
$page = $this->pageService->getPageByCodeName('specialisms');
$this->pageService->generateBreadcrumbTree($page, $this->links);
$otherLanguageRoutes = $this->languageService->getOtherLanguagesRoutes($page);
$page->translation = $this->decodeDynamicContent( $page->translation );
$specialisms = $this->specialismService->getAllSpecialisms();
// Return view
return \View::make($this->baseViewPath.$this->specialismPrefix.'index',[
'page' => $page,
'links' => $this->links,
'otherLanguages' => $otherLanguageRoutes,
'menuSpecialisms' => $specialisms,
]);
}
}