selectField = ["id", "name", "pid", "status", "created_at", "updated_at", "deleted_at"]; $this->queryField = ['name' => 'like','pid' => '=,status=']; $this->model = MallClassificationModel::class; } /** * 获取店铺行业列表 * @return array * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ public function list(): array { return $this->getPageList(); } /** * 获取店铺行业详情 * @param $id * @return mixed * @throws Exception */ public function detail($id) { return $this->getDetail($id); } /** * 店铺行业下拉列表 * @return mixed */ public function option() { $this->optionField = ['id', 'name', 'pid']; $this->where[] = ['pid', '=', 0]; $result = $this->getOption(); $result = $result->toArray(); $ids = array_column($result, 'id'); $this->whereIn = ['pid', $ids]; // 查询所有的子分类,然后放在父级分类下面 $this->where = [['deleted_at', '=', 0]]; $children = $this->getOption(); $children = $children->toArray(); $arr = array_merge($result, $children); $data = tree($arr); array_unshift($data, ['id' => 0, 'name' => '不分类', 'pid' => 0]); return $data; } /** * 创建店铺行业 * @param $params * @return mixed * @throws Exception */ public function create($params): mixed { return $this->insert($params); } /** * 编辑店铺行业 * @param $id * @param $params * @return mixed * @throws Exception */ public function update($id, $params): mixed { return $this->save($id, $params); } /** * 删除店铺行业 * @param $ids * @return mixed|true * @throws Exception */ public function delete($ids): mixed { return $this->del($ids); } }