如果$block->user_username
数据为空,则显示block
按钮,否则运行另一个if and else条件。但是在foreach循环中,其他方法无法正常工作@else <a href="#0" class="cd-popup-trigger">Block2</a>
,请任何人帮助我。
任何人都知道执行此操作的任何其他条件。
@else <a href="#0" class="cd-popup-trigger">Block2</a> @endif
仅当条件正常时,此条件才卡住。如果此@if(Auth::user()->name == $block->user_username && $user->username == $block->block_username)
条件为假,则代码不显示其他条件。
@foreach($blocked as $block)
@if(empty($block->user_username ))
<a href="#0" class="cd-popup-trigger">Block1</a>
@else
@if(Auth::user()->username == $block->user_username and $user->username == $block->block_username)
<a href="#0" class="cd-popup-trigger">Unblock</a>
@else
<a href="#0" class="cd-popup-trigger">Block2</a>
@endif
@endif
@endforeach
答案 0 :(得分:1)
尝试此代码
@foreach($blocked as $block)
@if(!empty($block->user_username ))
@if(Auth::user()->name == $block->user_username && $user->username == $block->block_username)
<a href="#0" class="cd-popup-trigger">Unblock</a>
@else
<a href="#0" class="cd-popup-trigger">Block2</a>
@endif
@else
<a href="#0" class="cd-popup-trigger">Block1</a>
@endif
@endforeach
我希望它将对您有帮助