query(); $vaccine = Vaccine::where('id', $req['id'])->first()->toArray(); $arr = VaccineAppoint::where('vaccine_id', $req['id'])->pluck('week_appoint')->toArray(); $content = new Content(); Admin::disablePjax(); $title = '['.$vaccine['name'].'] 可预约时间设置'; $data['req'] = $req; $data['data'] = $arr; return $content->title($title)->view('cdms/vaccine_setting_table', $data); } public function sumbit() { $req = request()->post(); if (empty($req['week_time_point_all']) && empty($req['week_time_point'])) { return out(null, 10001, '请勾选'); } VaccineAppoint::where('vaccine_id', $req['id'])->delete(); $appoint_week_arr = []; $map = [11 => '周一上午', 12 => '周二上午', 13 => '周三上午', 14 => '周四上午', 15 => '周五上午', 16 => '周六上午', 17 => '周日上午', 21 => '周一下午', 22 => '周二下午', 23 => '周三下午', 24 => '周四下午', 25 => '周五下午', 26 => '周六下午', 27 => '周日下午']; $tmp = []; if (empty($req['week_time_point_all']) && !empty($req['week_time_point'])) { foreach ($req['week_time_point'] as $k => $v) { VaccineAppoint::create(['vaccine_id' => $req['id'], 'week_appoint' => $v]); $i = $v + 10; if (in_array($i, $req['week_time_point'])) { $appoint_week_arr[] = mb_substr($map[$v], 0, 2).'全天'; $tmp[] = $i; } else { if (!in_array($v, $tmp)) { $appoint_week_arr[] = $map[$v]; } } } } $appoint_week_text = '不限'; if (!empty($appoint_week_arr)) { $appoint_week_text = implode(',', $appoint_week_arr); } Vaccine::where('id', $req['id'])->update(['appoint_week_text' => $appoint_week_text]); return out(); } }