我计划在用户通过身份验证后删除default.blade.php
中的@yield。我如何在if语句中执行此操作?
<ul class = "nav navbar-nav navbar-right">
@if (Auth::check()) <!-- Auth::check() method to test if the user is authenticated, and redirect the user -->
<!-- Auth::user() get the currently logged in user.-->
<li><a href = "#">Welcome {{ Auth::user()->getNameOrUsername() }}</a></li>
<li><a href = "#"><img src = "{{ asset('logos/home.png') }}"></a></li>
<li><a href = "#"><img src = "{{ asset('logos/account.png') }}"></a></li>
<li><a href = "{{ route('auth.logout') }}"><img src = "{{ asset('logos/logout.png') }}"></a></li>
@endif
</ul>
@if (Auth::check())
<div class = "container">
<a href = "#"><img src = "{{ asset('logos/preregistration.jpg') }}"></a>
<a href = "#"><img src = "{{ asset('logos/enrollment.jpg') }}"></a>
<a href = "#"><img src = "{{ asset('logos/studentgrades.jpg') }}"></a>
</div>
@endif
这是内容所属的母版页。 default.blade.php
<body>
@include ('templates.partials.navigation')
<div class = "container">
@include ('templates.partials.alerts')
@yield('content') {{-- @yield is always used to get content from a child page into master page. So this page will be master page. --}}
</div>
</body>
这是子页面。 home.blade.php
我计划在用户登录时删除标题。
@extends('templates.default') {{---Extending the folder template also the default.blade.php---}}
@section('content')
<h1>Welcome</h1>
@stop
答案 0 :(得分:0)
使用
@if (!(Auth::check())) @yield('content') @endif