所以这是我的问题。我正在尝试为两个表创建两个条目customer和booking。其中,customer id是预订表中的外键,是customer表中的主键。
我想做的是将新生成的客户id和预订id传递给同一控制器中的另一个函数(编辑函数),这样我就可以用生成的客户id更新预订表列。有没有简单的方法来完成这项工作。
$booking =new Booking;
$customer=new Customer;
$booking->piklocation=$request->input('piklocation');
$booking->date=$request->input('date');
$customer=new Customer;
$booking->save();
$customer->save();
return redirect()->route('booking.edit', $booking->id,$customer->id);
}
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id,$id2)
{
//Validation of the edit code
$booking = Booking::find($id);
$customer=Customer::find($id2);
return view('pages.vehicleselect')->with('booking',$booking)->with('customer',$customer);
}