我需要检查是否schedules_id等于请求,schedules_id然后需要检查profile“已预订”或“待定”,然后需要将所有“已预订”的profile seat值传递到blade.php中。我该怎么做,或者是否有其他方法或逻辑来做到这一点,请告诉我我是Laravel的新手
我现在如何获取数据:
class PassengersController extends Controller
{
public function booking(Request $request)
{
//river is used to pass important params with flow of it from page to page
$seat = $request->seat;
$buses_id = $request->buses_id;
$schedules_id = $request->schedules_id;
$data = Buses::where('buses_id', $buses_id)->first();
$seat = json_decode($data->seat_layout, true);
$front = json_decode($data->front_layout, true);
$bookingSeat = Bookings::whereColumn('schedules_id', 'schedules_id')->get();
$bookingSeat = $bookingSeat->map(function ($bookSeat) {
$bookSeat->seat = explode(",", $bookSeat->seat);
return $bookSeat;
});
return view('frontend.booking', ['seat' => $seat, 'buses_id' => $buses_id, 'schedules_id' => $schedules_id, 'front' => $front, 'bookingSeet' => $bookingSeat]);
}
}
blade.php
<div class="bus">
@foreach($seat as $key => $item)
@foreach($bookingSeet as $seer)
<div class="col-md-1">
<div class="seats back seats
@if(in_array($item['name'], $seer['seat']))
activeSeat
@endif"
data-id="{{$key}}">
<div class="special-attributes"></div>
@if(isset($item['name'])){{$item['name']}}@else 11A @endif
<input type="checkbox" name="seat_id[]" id="{{$key}}" value="{{$key}}">
</div>
</div>
@endforeach
@endforeach
</div>
桌子
bookings_id users_id schedules_id buses_id routes_id seat price profile
1 1 6 1 3 1 Null pending
2 1 6 1 3 2 Null booked
3 1 6 1 3 3 null booked
我当前代码的问题是在所有预订表列中获取2个数组,如何在我尝试将ex的复选框复制到刀片时,将该值传递给刀片服务器。一辆巴士有50个座位,但现在显示100个座位。像1,1,2,2这样的座位
慕斯709654
Qyouu
慕慕森