Laravel 问题:如何从@foreach 中排除@for 中的值
Laravel Question: How to exclude values from @foreach inside @for
这是我的问题,我想创建一个时间按钮,我的用户可以在其中 select 1 小时,我使用 for 循环在按钮中显示从 9:00 到 18:00,但我有一个 table,在这个 table 中我安排了约会,我有一个名为“时间”的列我想检查我的 [=24] 上是否存在时间=],这次显示为红色,如果我的 table 上不存在,请显示蓝色按钮。
@for($x = 9; $x <= 18; $x++)
@php
$time = $x.":00:00"; //To convert the number to time
@endphp
@foreach($Dates as $Date)
@if($Date->time == $time) // To check if the time exists o table
@if($Date->date == $datesaved) // To check if the day and month do it match
<input type="text" class="btn btn-danger w-100" value="{{$Date->time}}"><br/><br/>
@endif
@endif
@endforeach
<input type="text" class="btn btn-primary w-100" value="{{$x}}"><br/><br/>
@endfor
在所附的图片上,您可以看到我根据需要将按钮设置为蓝色和红色,但我有两次上午 10 点和下午 12 点,如何在我的@for 和@foreach 中排除它?
阿尔贝托
我解决了
的变化
@if($Cita->where('time','=',$time)->where('date','=',$datesaved)->count() > 0)
这是我的问题,我想创建一个时间按钮,我的用户可以在其中 select 1 小时,我使用 for 循环在按钮中显示从 9:00 到 18:00,但我有一个 table,在这个 table 中我安排了约会,我有一个名为“时间”的列我想检查我的 [=24] 上是否存在时间=],这次显示为红色,如果我的 table 上不存在,请显示蓝色按钮。
@for($x = 9; $x <= 18; $x++)
@php
$time = $x.":00:00"; //To convert the number to time
@endphp
@foreach($Dates as $Date)
@if($Date->time == $time) // To check if the time exists o table
@if($Date->date == $datesaved) // To check if the day and month do it match
<input type="text" class="btn btn-danger w-100" value="{{$Date->time}}"><br/><br/>
@endif
@endif
@endforeach
<input type="text" class="btn btn-primary w-100" value="{{$x}}"><br/><br/>
@endfor
在所附的图片上,您可以看到我根据需要将按钮设置为蓝色和红色,但我有两次上午 10 点和下午 12 点,如何在我的@for 和@foreach 中排除它?
阿尔贝托
我解决了
的变化 @if($Cita->where('time','=',$time)->where('date','=',$datesaved)->count() > 0)