File: D:/HostingSpaces/ASmits/kemi.nl/app/KommaApp/Kms/Composers/KmsSidebarMenuComposer.php
<?php namespace App\KommaApp\Kms\Composers;
/**
*
*
* @author Komma <info@komma.pro>
* @copyright (c) 2012-2016, Komma
*/
use App\KommaApp\Kms\Core\Kms;
use App\KommaApp\Kms\Core\KmsInterface;
use App\KommaApp\Shop\Bridges\SideBarShopMenuComposerBridge;
use App\KommaApp\Sites\Models\Site;
class KmsSidebarMenuComposer
{
protected $kms;
public function __construct()
{
$this->kms = \App::make(KmsInterface::class);
}
public function compose($view)
{
$viewData = $view->getData();
$currentSiteSlug = $this->kms->getSiteSlug();
//$currentSectionSlug = $this->getCurrentSectionSlug();
$currentSectionSlug = isset($viewData['section']) ? $viewData['section']->getSlug() : $this->getCurrentSectionSlug();
$currentSectionSubSlug = $this->getCurrentSectionSubSlug();
//Load all the available sites
$sites = $this->kms->getSites();
$site = $sites->first();
$menuStructure = [
[
'name' => \Lang::get('kms/SidebarMenu.users'),
'url' => route('users.index'),
'active' => ('users' == $currentSectionSlug)
],
[
'name' => \Lang::get('kms/SidebarMenu.pages'),
'url' => route('pages.index', ['site' => $site->slug]),
'active' => ('pages' == $currentSectionSlug && $site->slug == $currentSiteSlug)
],
[
'name' => \Lang::get('kms/SidebarMenu.products'),
'url' => route('projects.index'),
'active' => ('projects' == $currentSectionSlug)
],
[
'name' => 'Nieuws',
'url' => route('posts.index'),
'active' => ('posts' == $currentSectionSlug)
],
['name' => 'Machines', 'url' => route('machines.index'), 'active' => ('machines' == $currentSectionSlug)],
['name' => 'Vacatures', 'url' => route('jobs.index'), 'active' => ('jobs' == $currentSectionSlug)],
];
$view->with('menuStructure', $menuStructure);
}
protected function getCurrentSectionSlug()
{
$route = explode('/', \Route::current()->uri());
if (\Route::current()->parameter('site')) {
return $route[2];
}
return isset($route[1]) ? $route[1] : null;
}
protected function getCurrentSectionSubSlug()
{
$route = explode('/', \Route::current()->uri());
if (\Route::current()->parameter('site')) {
if (isset($route[3])) return $route[3];
}
return isset($route[2]) ? $route[2] : null;
}
}