【发布时间】:2022-11-16 14:38:01
【问题描述】:
当我尝试提交这样的预订表格时:
How many book : 2
Name : a
email : a@gmail.com
email#1 : b@gmail.com
在数据库中:
ID : 1
Name : a
Email : a@gmail.com
Other email : NULL
ID : 2
Name : NULL
Email : NULL
Other email : b@gmail.com
我怎样才能使 ID 号 2 的名称和电子邮件的值不为空 但相反是
ID : 2
Name : a
Email : a@gmail.com
Other email : b@gmail.com
控制器:
$firstName = $booking->first_name;
$lastName = $booking->last_name;
foreach ($request->input('other_emails') as $email){
Booking::create([
'first_name'=>$firstName,
'last_name'=>$lastName,
'other_emails'=>$email
]);
Mail::to($email)->send(new OthersEmail($isi_email1));
}
该模型 :
protected $fillable = [
'first_name',
'last_name',
'other_emails'
];
【问题讨论】: