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/tandartsmaas.komma.pro/app/Komma/Navigation/NavigationService.php
<?php


namespace Komma\Navigation;

use Komma\Pages\PageEntity;

class NavigationService
{
    protected $pages;
    protected $mainNavigation;

    public function __construct()
    {
        $this->pages = \Config::get('komma.pages');
    }

    public function main()
    {
        $list = [];

        foreach(\Config::get('komma.mainNavigation') as $item)
        {
            $list[$item] = $this->addEntity($item);
        }

        return $list;
    }

    public function other()
    {
        $list = [];

        foreach(\Config::get('komma.otherPagesNavigation') as $item)
        {
            $list[$item] = $this->addEntity($item);
        }

        return $list;
    }

    public function services()
    {
        $list = [];

        // Loop through items
        foreach(\Config::get('komma.subServicesNavigation') as $item)
        {
            $list[$item] = $this->addEntity($item);
        }

        return $list;
    }

    public function practice()
    {
        $list = [];

        // Loop through items
        foreach(\Config::get('komma.subPracticeNavigation') as $item)
        {
            $list[$item] = $this->addEntity($item);
        }

        return $list;
    }

    public function addEntity($item)
    {
        $label = \Lang::get('pages.' . $item . '.label');
        $route = \Lang::get('pages.' . $item . '.route');

        if(empty($route)) $route = '/';

        $pageEntity = new PageEntity([
            'name' => $item,
            'label' => $label,
            'route' => $route,
        ]);

        return $pageEntity;
    }

    public function getActiveEntity($currentPageName)
    {
        $currentEntity = $this->addEntity($currentPageName);

        foreach(\Config::get('komma.mainNavigation') as $item)
        {
            $pageEntity = $this->addEntity($item);
            if($pageEntity->isActive($currentEntity)) echo $pageEntity->name;
        }
    }

    public function route($name)
    {
        return \Lang::get('pages.' . $name . '.route');
    }

}