model = CardClassModel::class; $this->selectField = ['id', 'name', 'status', 'created_at', 'updated_at']; $this->queryField = ['name' => 'like', 'status' => '=']; $this->orderBy = ['name' => 'id', 'sort' => 'asc']; } /** * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ public function list(): array { return $this->getPageList(); } public function option(): mixed { return $this->getOption(); } /** * @throws Exception */ public function detail($id): mixed { return $this->getDetail($id); } public function create($params): mixed { return $this->insert($params); } /** * @throws Exception */ public function update($id, $params): mixed { return $this->save($id, $params); } /** * @throws Exception */ public function delete($id): mixed { $ids = array_values(array_filter(array_map('intval', is_array($id) ? $id : [$id]))); if (empty($ids)) { $this->utils->errorThrow('参数错误'); } if (ColorcardModel::whereIn('card_class', $ids)->where('deleted_at', 0)->exists()) { $this->utils->errorThrow('该分类下仍有色卡,请先调整色卡分类'); } return $this->del($ids); } /** * @throws Exception */ public function status($id, $status): mixed { return $this->save($id, ['status' => (int) $status]); } }