gpt4 book ai didi

javascript - 如果条件为真显示阻止按钮否则条件为假显示取消阻止按钮 : Laravel, Javascript

转载 作者:行者123 更新时间:2023-11-30 19:32:39 25 4
gpt4 key购买 nike

如果$block->user_username数据空显示block按钮 else 运行另一个 if 和 else 条件。但在 foreach 循环中,否则无法正常工作 @else <a href="#0" class="cd-popup-trigger">Block2</a>请任何人帮助我。任何人都知道做这件事的任何其他条件。

@else <a href="#0" class="cd-popup-trigger">Block2</a> @endif仅当条件有效时,此 else 条件才会卡住。如果这个@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

希望对你有帮助

关于javascript - 如果条件为真显示阻止按钮否则条件为假显示取消阻止按钮 : Laravel, Javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56279319/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com