HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/kemi.komma.pro/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;
    }
}