我对 laravel 的 phpmyadmin 有疑问 我想通过控制器更新数据库视图中的数据,但出现错误
// save all seats
foreach ($request->all() as $key => $param) {
if ($key === '_token') continue;
$data = explode('-', $key);
$bs = new BookedSeat();
$bs->booking_id = $booking->id;
$bs->day_id = str_replace('c', '', $data[0]);
$bs->table_id = str_replace('t', '', $data[1]);
$bs->number = 0;
$bs->status = 'requested';
$bs->save();
}
更新了
// save all seats
foreach ($request->all() as $key => $param) {
if ($key === '_token') continue;
$data = explode('-', $key);
$bs = new BookedSeat();
$bs->booking_id = $booking->id;
$day = DB::table('days')->where('name',$data[0])->get();
$bs->day_id = $day->id;
$bs->table_id = str_replace('t', '', $data[1]);
$bs->number = 0;
$bs->status = 'requested';
$bs->save();
}