model = new Schedules(); } /** * 获取排班管理列表 * @param array $where * @return array */ public function getPage(array $where = []) { $field = 'id,staff_id,class_id,date_time,time_slot,task,is_deleted,create_time,update_time,created_by,created_role,updated_by,updated_role'; $order = 'id desc'; $search_model = $this->model->withSearch(["staff_id","class_id","date_time","task","create_time"], $where)->with(['staff','classes'])->field($field)->order($order); $list = $this->pageQuery($search_model); return $list; } /** * 获取排班管理信息 * @param int $id * @return array */ public function getInfo(int $id) { $field = 'id,staff_id,class_id,date_time,time_slot,task,is_deleted,create_time,update_time,created_by,created_role,updated_by,updated_role'; $info = $this->model->field($field)->where([['id', "=", $id]])->with(['staff','classes'])->findOrEmpty()->toArray(); return $info; } public function get_info(array $data) { $field = 'id,staff_id,class_id,courses_id,date_time,time_slot,task'; $info = $this->model->field($field)->where($data)->findOrEmpty()->toArray(); $info['time_slot'] = explode(",",$info['time_slot']); return $info; } /** * 添加排班管理 * @param array $data * @return mixed */ public function add(array $data) { $data['time_slot'] = implode(",",$data['time_slot']); $res = $this->model->create($data); return $res->id; } /** * 排班管理编辑 * @param int $id * @param array $data * @return bool */ public function edit(int $id, array $data) { $data['time_slot'] = implode(",",$data['time_slot']); $this->model->where([['id', '=', $id]])->update($data); return true; } /** * 删除排班管理 * @param int $id * @return bool */ public function del(int $id) { $model = $this->model->where([['id', '=', $id]])->find(); $res = $model->delete(); return $res; } public function getStaffAll(){ $staffModel = new Staff(); return $staffModel->select()->toArray(); } public function getClassesAll(){ $classesModel = new Classes(); return $classesModel->select()->toArray(); } }