categoryModel->get(['category.id','category.name','category.image_id']); if (empty($list)) return $this->return->success('success',['list' => []]); return $this->return->success('success',['list' => $list->toArray()]); } /** * 添加 * @return array * @throws Exception */ public function add() { $name = $this->request->input('name'); $imageId = $this->request->input('image_id'); $this->updateOssObjects([$imageId]); $category = new Category(); $category->name = $name; $category->image_id = $imageId; if (!$category->save()) throw new ErrException('商品种类添加失败'); return $this->return->success(); } }