<nav class="navbar navbar-expand-lg navbar-light bg-white">
    <div class="container">
        <a class="navbar-brand" href="#index.html">BG Website CMS</a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>

        <div class="collapse navbar-collapse" id="navbarNav">
            <ul class="navbar-nav ms-auto">
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="java:void(0)" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                        <?php echo"User"?>
                    </a>
                    <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
                        <li>
                            <a class="text-center dropdown-item" href="java:void(0)">
                                <?php
                                $session = $this->request->getSession();
                                $user = $session->read('Auth.User');

                                if (!empty($user['first_name']) && !empty($user['last_name'])) {
                                    echo $user['first_name'] . ' ' . $user['last_name'];
                                }
                                ?>
                            </a>
                        </li>
                        <li><hr class="dropdown-divider"></li>
                        <li>
                            <?php echo $this->Html->link(__('Register'), ['controller' => 'Users', 'action' => 'register'], ['class' => "dropdown-item"]); ?>
                        </li>
                        <li><hr class="dropdown-divider"></li>
                        <li>
                            <?php echo $this->Html->link(__('Logout'), ['controller' => 'Users', 'action' => 'logout'], ['class' => "dropdown-item"]); ?>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
</nav>
