我有通过jquery表单提交的数据
"<tr><td><input type='checkbox' name='record'></td><td><input name='subjects[]' class='form-control' disabled value='" + name + "'></td><td><input class='form-control' disabled value='" + staff + "'></td><td><input type='hidden' name='staffs[]' class='form-control' value='" + staff_id + "'></td></tr>"
在我的控制器(SubjectsController.php)中,我有
public function store(Request $request)
{
$subjects = array();
$subjects = $request->subjects;
$staff = $request->staffs;
$subjectSet = [];
foreach($subjects as $subject){
$subjectSet[] = [
'schoolclass_id' => $request->schoolclass_id,
'name' => $subject,
'staff_id' => $staff
];
}
DB::table('subjects')->insert($subjectSet);
提交此文件时,我不断收到为foreach()提供的无效参数