为什么我的路线守卫没有显示默认页面?

时间:2019-12-15 07:14:11

标签: php laravel authentication routes authorization

我尝试不登录并转到http://localhost:8000/Dashboard。它不应授权某人访问该页面并再次路由到登录页面。但是,它只显示错误:

  

试图获取非对象的属性“名称”(视图:C:\ xampp \ htdocs \ inventoryApp \ resources \ views \ layouts \ home.blade.php)(视图:C:\ xampp \ htdocs \ inventoryApp \资源\视图\布局\ home.blade.php)

我不确定为什么我的路线守卫显示该错误。我正在使用laravel 5.4

这是我的home.blade.php代码:

<div class="wrapper">
    <header class="main-header">
        <a href="/Dashboard" class="logo">
            <span class="logo-mini"><b>OS</b>IS</span>
            <span class="logo-lg"><b>INVENTORY</b>SYSTEM</span>
        </a>
        <nav class="navbar navbar-static-top" role="navigation">
            <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
                <span class="sr-only">Toggle navigation</span>
            </a>
            <div class="navbar-custom-menu">
                <ul class="nav navbar-nav">
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
                            {{ Auth::user()->name }} <span class="caret"></span>
                        </a>
                        <ul class="dropdown-menu" role="menu">
                            <li>
                                <a href="{{ route('logout') }}"
                                    onclick="event.preventDefault();
                                            document.getElementById('logout-form').submit();">
                                    <i class="fa fa-fw fa-power-off"></i> Log Out
                                </a>
                                <form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
                                    {{ csrf_field() }}
                                </form>
                            </li>
                        </ul>
                    </li>
                </ul>
            </div>
        </nav>
    </header>

    <aside class="main-sidebar">
        <section class="sidebar">
            <ul class="sidebar-menu" data-widget="tree">
                {{-- <li class="{{  request()->is('Dashboard') ? 'active' : ''  }}"><a href="{{ url('/Dashboard') }}"><i class="fa fa-dashboard"></i> <span>Dashboard</span></a></li> --}}
                <li class="header">SALE</li>
                <li class="{{  request()->is('Cart/*') ? 'active' : ''  }}"><a href="{{ route('Cart.index') }}"><i class="fas fa-dollar-sign"></i> <span>New Sale</span></a></li>        
                <li class="{{  request()->is('sale/*') ? 'active' : ''  }}"><a href="{{ route('Sale.index') }}"><i class="fas fa-dollar-sign"></i> <span>View Sale</span></a></li>        
                <li class="header">ORDER</li>
                <li class="{{  request()->is('Order/*') ? 'active' : ''  }}"><a href="{{ route('Order.create') }}"><i class="fas fa-shopping-cart"></i> <span>New Order</span></a></li>        
                <li class="{{  request()->is('Order') ? 'active' : ''  }}"><a href="{{ route('Order.index') }}"><i class="fas fa-shopping-cart"></i> <span>View Order</span></a></li>        
                <li class="header">ITEM</li>
                <li class="{{  request()->is('Item/create') ? 'active' : ''  }}"><a href="{{ route('Item.create') }}"><i class="fas fa-box-open"></i> <span>New Item</span></a></li>        
                <li class="{{  request()->is('Item') ? 'active' : ''  }}"><a href="{{ route('Item.index') }}"><i class="fas fa-box-open"></i> <span>View Item</span></a></li>        
                <li class="header">USER</li>
                <li class="{{  request()->is('User/create') ? 'active' : ''  }}"><a href="{{ route('User.create') }}"><i class="fas fa-user-alt"></i> <span>New User</span></a></li>        
                <li class="{{  request()->is('User') ? 'active' : ''  }}"><a href="{{ route('User.index') }}"><i class="fas fa-user-alt"></i> <span>View User</span></a></li>        
            </ul>
        </section>
    </aside>
<div class="content-wrapper">
    <section class="content">     
        @include('inc.messages')
        @yield('content')
    </section>
</div>
@include('inc.footer')
<div class="control-sidebar-bg"></div>

0 个答案:

没有答案