@nicho it will be helpful next time to explain what's wrong with your current way
As for now, I see
I added order_id column in the booking table
But in code you get id
$order_id = $booking->id;
Should it be order_id?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi i'm currently developing a website, and trying to implementing a feature book for others. I tried to do this with an array. So scenario is like this, user want to buy 5 tour packages for that user itself and the user friends, when input the booking form, the user also need to fill 4 of the friends email, to notify them that they got the tour package. I added order_id column in the booking table, the purpose of order_id is to get the id of booking table, everytime the other emails is input and save into the database, the order_id value is the same as the id of that booking. Example :
How many books : 2
Booking ID : 1
Your email : [email protected]
Email#1 : [email protected]
In the database it should be like this :
ID : 1
email : [email protected]
order_id : 1
ID : 2
email : [email protected]
order_id : 1
How can i do it??
The Model :
protected $fillable = [
'order_id',
'other_emails'
];
The Controller :
$order_id = $booking->id;
$numbers = $booking->total_guests;
foreach($request->input('other_emails') as $other_emails){
Booking::create([
'other_emails'=>$other_emails,
'order_id'=>$order_id,
]);
}
Please or to participate in this conversation.