如果 $block->user_username
数据空显示 block
按钮否则会在其他条件下运行另一个条件。但是在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
尝试此代码
@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
我希望它会有所帮助