美文网首页
laravel balde自带判断方法@guest 游客

laravel balde自带判断方法@guest 游客

作者: wj_39ed | 来源:发表于2020-09-11 16:38 被阅读0次

    @guest 判断是否为游客

    //在登录时会使用
    <ul class="navbar-nav navbar-right">
            <!-- Authentication Links 游客,blade的判断方法guest-->
            @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 dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                        <img src="https://cdn.learnku.com/uploads/images/201709/20/1/PtDKbASVcz.png?imageView2/1/w/60/h/60" class="img-responsive img-circle" width="30px" height="30px">
                        {{ Auth::user()->name }}
                    </a>
                    <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                        <a class="dropdown-item" id="logout" href="#"
                           onclick="event.preventDefault();document.getElementById('logout-form').submit();">退出登录</a>
                        <form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
                            {{ csrf_field() }}
                        </form>
                    </div>
                </li>
            @endguest
        </ul>
    

    退出登录的a链接

    <a class="dropdown-item" id="logout" href="#"
                           onclick="event.preventDefault();document.getElementById('logout-form').submit();">退出登录</a>
                        <form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
                            {{ csrf_field() }}
                        </form>
    

    相关文章

      网友评论

          本文标题:laravel balde自带判断方法@guest 游客

          本文链接:https://www.haomeiwen.com/subject/srrbektx.html