model = new CustomerResources(); } /** * 获取客户资源列表 * @param array $where * @return array */ public function getPage(array $where = []) { $field = 'id,create_year_month,create_date,source,source_channel,consultant,name,age,gender,phone_number,demand,purchasing_power,cognitive_idea,optional_class_time,distance,decision_maker,initial_intent,campus,created_at,updated_at,deleted_at,status'; $order = 'id desc'; $search_model = $this->model->where(get_campus_where($this->uid))->withSearch(["name","phone_number"], $where)->with(['campus'])->field($field)->order($order); $list = $this->pageQuery($search_model); return $list; } /** * 获取客户资源信息 * @param int $id * @return array */ public function getInfo(int $id) { $field = 'id,create_year_month,create_date,source,source_channel,consultant,name,age,gender,phone_number,demand,purchasing_power,cognitive_idea,optional_class_time,distance,decision_maker,initial_intent,campus,created_at,updated_at,deleted_at,status'; $info = $this->model->field($field)->where([['id', "=", $id]])->findOrEmpty()->toArray(); return $info; } /** * 添加客户资源 * @param array $data * @return mixed */ public function add(array $data) { $data['consultant'] = $this->username; $res = $this->model->create($data); return $res->id; } /** * 客户资源编辑 * @param int $id * @param array $data * @return bool */ public function edit(int $id, array $data) { $data['consultant'] = $this->username; $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 getCampusAll(){ $campusModel = new Campus(); return $campusModel->select()->toArray(); } }