Laravel: How to write href attribute based on if-else condition?
P粉852578075
P粉852578075 2023-08-31 17:37:25
0
1
439
<p>我需要在 if-else 子句中通过 URL 检查“perPage=100”和“perPage=50”。</p> <pre class="brush:php;toolbar:false;">@if(perPage=100) <a class="btn btn-default btn-sm ajax-link back-btn" href="invoice-list?perPage=100" type="button" >Back to List</a> @elseif(perPage=50) <a class="btn btn-default btn-sm ajax-link back-btn" href="invoice-list?perPage=50" type="button" >Back to List</a> @else <a class="btn btn-default btn-sm ajax-link back-btn" href="invoice-list?perPage=10" type="button" >Back to List</a> @endif</pre></p>
P粉852578075
P粉852578075

reply all(1)
P粉289775043

You can only write this line without any if:

<a class="btn btn-default btn-sm ajax-link back-btn" href="{{url('invoice-list?perPage=' . $perPage)}}" type="button">Back to List</a>

Make sure you have the $perPage variable

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template