General error: 1364 Field 'challen_student_id' doesn't have a default value (SQL: insert into challens (updated_at, created_at) values (2022-10-04 08:53:41, 2022-10-04 08:53:41))
$students = Student::all('id');
$collection = collect($students)->map(function ($student) use($request) {
$collect = collect(['challen_student_id', 'challen_month', 'challen_due_date', 'challen_fine', 'challen_exam_fees', 'challen_status']);
return $collect->combine([$student->id, $request->item['challen_month'], $request->item['challen_due_date'], $request->item['challen_fine'], $request->item['challen_exam_fee'], 'pending'])->toArray();
// [enter image description here][1]
});
// print_r($collection->toarray());
// exit;
Challen::create($collection->toArray());
print_r result is
Array (
[0] => Array (
[challen_student_id] => 1
[challen_month] =>
[challen_due_date] =>
[challen_fine] =>
[challen_exam_fee] =>
[challen_status] => pending
)
)