![](/img/trans.png)
[英]Laravel: How to get data from View/Blade and pass to Controller
[英]Get tags in view blade depending on how data is cycled
我有下面顯示的代碼。
循環診所; 對於每個響應,如果診所 ID 對應於響應中存在的診所 ID,並且如果客人 ID 對應於響應中存在的客人 ID,我希望它打印響應日期,否則按鈕添加響應。
正如我所做的那樣,代碼向我打印了多少個按鈕(即使存在日期)和多少個響應,而正如我上面所說的,我只想在日期不存在時獲取按鈕。
<table id="tabledata" class="table table-striped hover">
<thead>
<tr>
<th>Surname</th>
<th>Name</th>
<th>Phone</th>
@foreach($clinics as $clinic)
<th>{{$clinic->name}}</th>
@endforeach
</tr>
</thead>
<tbody>
@foreach ($guests as $guest)
<tr>
<td>{{ $guest->surname }}</td>
<td>{{ $guest->name }}</td>
<td> <a href="tel:{{ $guest->phone }}"> {{ $guest->phone }}</a></td>
@foreach($clinics as $clinic)
<td>
@foreach($guest_responses as $guest_response)
@if(($guest->id == $guest_response->guest_id) && ($clinic->id == $guest_response->clinic_id))
<p>{{$guest_response->date}}</p>
@endif
<button type="button" class="btn btn-success buttonclinic" data-bs-toggle="modal" data-bs-target="#responseModal" data-id-clinic="{{$clinic->id}}" data-id-guest="{{$guest->id}}" data-name-clinic="{{$clinic->name}}" data-surname-guest="{{ $guest->surname }}" data-name-guest="{{ $guest->name }}"><i class="fa-regular fa-plus"></i></button>
@endforeach
</td>
@endforeach
</tr>
@endforeach
</tbody>
</table>
誰能幫我?
如何添加一個標志來檢查帶有日期的響應?
<td>
@php
$exist_response_date = false;
@endphp
@foreach($guest_responses as $guest_response)
@if(($guest->id == $guest_response->guest_id) && ($clinic->id == $guest_response->clinic_id))
@php
if($guest_response->date) {
$exist_response_date = true;
}
@endphp
<p>{{$guest_response->date}}</p>
@endif
@endforeach
@if(!$exist_response_date)
<button type="button" class="btn btn-success buttonclinic" data-bs-toggle="modal" data-bs-target="#responseModal" data-id-clinic="{{$clinic->id}}" data-id-guest="{{$guest->id}}" data-name-clinic="{{$clinic->name}}" data-surname-guest="{{ $guest->surname }}" data-name-guest="{{ $guest->name }}"><i class="fa-regular fa-plus"></i></button>
@endif
</td>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.