<nav class="navbar navbar-expand-lg navbar-light bg-light navbar-static-top">
    <div class="container">
        <!-- Branding Images -->
        <a class="navbar-brand " href="{{ url('/') }}">
            我看看不到博客
        </a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
                aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>

        <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <div class="d-lg-none" style="margin-top:10px;">
                <form class="ui fluid category item secondary hide-on-991 searchInputDiv" action=""
                      method="GET">
                    <div class="ui icon input">
                        <input class="searchInput" style="border-radius: 3px;" name="q" type="text" placeholder="搜索" value=""
                               autocomplete="off">
                        <i class="fa fa-search icon"></i>
                    </div>
                    <div class="results transition visible">
                    </div>
                </form>
            </div>

            <!-- Left Side Of Navbar -->
            <ul class="navbar-nav mr-auto"  <?php if(in_array(route_class(),
                [
                    'posts-create',
                    'posts-edit',
                ]))
            { echo 'style="position:relative;top:7px;"';} ?> >

                <li class="nav-item {{ checkQuery('cate') }}">
                    <a class="nav-link" href="{{ route('posts.index') }}">话题</a>
                </li>
                <?php $categories = \App\Models\Category::all(); ?>
                @foreach ($categories as $category)
                    <li class="nav-item  {{checkQuery('cate',$category->id)}}">
                        <a class="nav-link" href="{{ route('posts.index', ['cate'=>$category->id]) }}">
                            {{$category->title}}
                        </a>
                    </li>
                @endforeach
                <li class="nav-item d-none d-lg-block">
                    <form class="ui fluid category search item secondary hide-on-991 searchInputDiv" action=""
                          method="GET">
                        <div class="ui icon input">
                            <input class="prompt searchInput" name="q" type="text" placeholder="搜索" value=""
                                   autocomplete="off">
                            <i class="fa fa-search icon"></i>
                        </div>
                        <div class="results transition visible">


                        </div>
                    </form>
                </li>
            </ul>
            <!-- Right Side Of Navbar -->
            <ul class="navbar-nav navbar-right">
                <!-- Authentication Links -->
                @guest
                    <li class="nav-item"><a class="nav-link" href="{{ route('login') }}">登录</a></li>
                    <li class="nav-item"><a class="nav-link" href="{{ route('register') }}">注册</a></li>
                @else
                    <li class="nav-item">
                        <a class="nav-link mt-1 mr-3 font-weight-bold" href="{{ route('posts.create') }}">
                            <i class="fa fa-plus"></i> 新建话题
                        </a>
                    </li>
                    <li class="nav-item notification-badge">
                        <a class="nav-link mr-3 badge badge-pill badge-{{ Auth::user()->notification_count > 0 ? 'hint' : 'secondary' }} text-white"
                           href="{{ route('notifications.index') }}">
                            {{ Auth::user()->notification_count ? Auth::user()->notification_count : 0 }}
                        </a>
                    </li>
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button"
                           data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                            <img src="{{ Auth::user()->avatar }}"
                                 class="img-responsive img-circle" width="30px" height="30px">
                            {{ Auth::user()->name }}
                        </a>
                        <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                            <a class="dropdown-item" href="{{ route('users.show', Auth::id()) }}">
                                <i class="far fa-user mr-2"></i>
                                个人中心
                            </a>
                            <a class="dropdown-item" href="{{ route('users.edit', Auth::id()) }}">
                                <i class="far fa-edit mr-2"></i>
                                编辑资料
                            </a>
                            <div class="dropdown-divider"></div>
                            <a class="dropdown-item" id="logout" href="#">
                                <form action="{{ route('logout') }}" method="POST"
                                      onsubmit="return confirm('您确定要退出吗？');">
                                    {{ csrf_field() }}
                                    <button class="btn btn-block btn-danger" type="submit" name="button">退出</button>
                                </form>
                            </a>
                        </div>
                    </li>
                @endguest
            </ul>
        </div>
    </div>
</nav>
