<?php
/**
 * Package Navigation Service Provider Class
 *
 * @version     1.0.$Revision:$
 * @version     SVN: $Id:$
 * @package     bplan-base/globals
 * @subpackage  Providers
 * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
 * @copyright   Copyright (C) 2025 Wassilios Meletiadis <https://www.bplan-solutions.de/>
 * /Δ\
 */

namespace BplanBase\Globals\Providers;

// @todo    Visit-Komponenten entfernen
use BplanBase\Globals\Foundation\Support\BaseNavigationServiceProvider;
use BplanBase\Globals\Models\User;
use BplanBase\Globals\ViewModels\MenuItem;
use BplanModules\VisitorManagement\Enums\VisitTypeIdentifier;
use BplanModules\VisitorManagement\Models\VisitType;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;


// use BplanBase\Globals\Services\Menu\MenuItem;


/**
 * Package Navigation Service Provider Class
 *
 * @version     1.0.0 / 2026-02-26
 * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
 */
class CoreNavigationServiceProvider extends BaseNavigationServiceProvider
{


/* +++ TRAITS +++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */


/* +++ CLASS CONSTANTS +++ ++++++++++++++++++++++++++++++++++++++++++++++++++ */


/* +++ OBJECT MEMBERS +++ +++++++++++++++++++++++++++++++++++++++++++++++++++ */


    /**
     * @var     string
     */
    protected string $_packagePrefix = 'core';


/* +++ CLASS MEMBERS +++ ++++++++++++++++++++++++++++++++++++++++++++++++++++ */


/* +++ OBJECT METHODS +++ +++++++++++++++++++++++++++++++++++++++++++++++++++ */


    /**
     * Bootstrap services
     *
     * @param       Request $Request
     *
     * @return      void
     *
     * @version     1.0.0 / 2026-02-26
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public function boot(Request $Request): void
    {
        View::composer('globals::layouts.module-frame.sidebar', function ($View) use ($Request) {
            $currentModule = \Registry::get('env.currentModule');

            if ($currentModule !== 'core') {
                return;
            }
            $this->_Request = $Request;
            // $User = Auth::user() ?? new User();

            $order = 0;
            /*
            **  Collect the menu items for the sidebar. Add dashboard. */
            $sidebarMenuItems = [
                $this->_getMenuItem('dashboard', ++$order)
            ];
            foreach (config('globals.core.navigation') as $key => $status) {
                if ($status !== true) {
                    continue;
                }
                $sidebarMenuItems[] = $this->_getMenuItem($key, ++$order);
            }
             $View->with('sidebarMenuItems', $sidebarMenuItems);
        });
    } // boot()


    /**
     * Register services
     *
     * @return      void
     *
     * @version     1.0.0 / 2025-08-10
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     */
    public function register(): void
    {
        //
    } // register()


/* +++ CLASS METHODS +++ ++++++++++++++++++++++++++++++++++++++++++++++++++++ */


} // class CoreNavigationServiceProvider extends BaseNavigationServiceProvider {}
