$module_data = array();
foreach ($course_module as $k => $v) {
$module_data[] = [
'user_course_id' => $orm->id,
'course_id' => $request->course_id,
'user_id' => $request->user_id,
'course_module_id' => $v['id'],
];
}
UserCourseModule::insert($module_data);
https://stackoverflow.com/questions/39113682/insert-multiple-records-at-once-with-laravel