我正在尝试制作一个前端时间表,您可以在其中单击一个单元格,例如在第8:30行,然后弹出一个模式,您可以选择直到您将从9:00开始保留该单词以半小时为增量。
只保留一个术语可以正常工作,因为我可以直接从循环中选择变量,但是我对如何将它转发到模态有疑问。
控制器:
public function index()
{
$scheduler_start_time = Carbon::createFromTime(6, 0, 0);
$scheduler_end_time = Carbon::createFromTime(20, 0, 0);
$equipment = Equipment::with('reservations', 'reservations.user')->get();
return view('landing', compact('equipment', 'scheduler_start_time', 'scheduler_end_time'));
}
前端的表循环:
@while($scheduler_start_time < $scheduler_end_time)
<tr>
<td>{{$scheduler_start_time->format('H:i:s')}}</td>
@foreach($equipment as $instrument)
<td>
<a href="#" style="display: block;"
data-href="{{route('reserve-me', [$instrument->id, $scheduler_start_time->timestamp])}}"
data-toggle="modal" data-target="#confirm-reservation">
@if(!$instrument->reservations->where('reserved_from', $scheduler_start_time)->isEmpty())
{{$instrument->reservations->where('reserved_from', $scheduler_start_time)->first()->user->name}}
@else
@endif
</a>
</td>
@endforeach
<?php $scheduler_start_time->addMinutes(30) ?>
</tr>
@endwhile
模态:
<!-- Modal -->
<div class="modal fade" id="confirm-reservation" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
New reservation
</div>
<div class="modal-body">
Are you sure you want to add this reservation?
<br><br>
<div class="dropdown">
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">Reserve until
<span class="caret"></span></button>
<ul class="dropdown-menu">
<!-- *CLARIFICATION -->
<li><a href="#">{{$scheduler_start_time}}</a></li>
</ul>
</div>
</div>
<div class="modal-footer">
<a class="btn btn-primary btn-ok">Yes</a>
<button type="button" class="btn btn-default" data-dismiss="modal">No</button>
</div>
</div>
</div>
</div>
<script>
$('#confirm-reservation').on('show.bs.modal', function(e) {
$(this).find('.btn-ok').attr('href', $(e.relatedTarget).data('href'));
});
</script>
它在哪里说明*澄清:我正在尝试小步骤,至少得到我点击的价值,但我总是得到最后时间20:00h