File: D:/HostingSpaces/Lacom/lacom.nl/app/KommaApp/Segments/SegmentController.php
<?php
namespace App\KommaApp\Segments;
use App\Http\Controllers\Controller;
use App\KommaApp\Segments\Models\Segment;
class SegmentController extends Controller
{
private $segmentPrefix = 'pages.segments.';
protected $segmentService;
public function __construct(SegmentService $segmentService)
{
parent::__construct();
$this->segmentService = $segmentService;
}
/**
* @param Segment $segment
* @return \Illuminate\Contracts\View\View
*/
public function show(Segment $segment)
{
// Load translation by eager loading
$segment->load( 'translation');
// Get overview page
$page = $this->pageService->getPageByCodeName('segments');
$page->translation = $this->decodeDynamicContent( $page->translation );
// Generate page breadcrumb
$this->pageService->generateBreadcrumbTree($page, $this->links);
// Expend breadcrumb with the current segment
$this->segmentService->expandBreadCrumbTree($page, $segment, $this->links);
// Check if given Segment belongs to the set site
if($segment->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($segment);
$page->preventFooterActive = true;
$segments = $this->segmentService->getAllSegments();
// Determine the segments for the after content menu
$this->segmentService->makeNextSegments($segment, $segments);
// Determine the reference used on the page because we always want one
$this->referenceService->determineReferenceAndShareWithViews($segment);
// Return view
return \View::make($this->baseViewPath.$this->segmentPrefix. 'show',[
'page' => $page,
'segment' => $segment,
'links' => $this->links,
'menuSegments' => $segments,
// 'otherLanguages' => $otherLanguageRoutes,
]);
}
public function index(){
$page = $this->pageService->getPageByCodeName('segments');
$this->pageService->generateBreadcrumbTree($page, $this->links);
$otherLanguageRoutes = $this->languageService->getOtherLanguagesRoutes($page);
$page->translation = $this->decodeDynamicContent( $page->translation );
// $segments = $this->segmentService->getAllSegments();
// Return view
return \View::make($this->baseViewPath.$this->segmentPrefix.'index',[
'page' => $page,
'links' => $this->links,
'otherLanguages' => $otherLanguageRoutes,
// 'menuSegments' => $segments,
]);
}
}