2
私のdefault.blade.php
で@yieldを削除する予定です。ユーザーが認証されたときです。 if文の中でこれをどうすればできますか?ユーザーが認証されたときに@yieldを削除するにはどうすればよいですか?
<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
あなただけyeld' @ '削除したい場合は、単に' if'文でそれを包みます。より正確に記述しようとしない場合。ありがとう – Pyton
@Pytonいいえこれは動作しません。私はちょうど私の '@収率'を複製する – Francisunoxx