getList($this->postData()); return $this->renderSuccess('', compact('list')); } /** * 添加年卡套餐 */ public function add() { $model = new MemberPlanModel; if ($model->add($this->postData())) { return $this->renderSuccess('添加成功'); } return $this->renderError($model->getError() ?: '添加失败'); } /** * 编辑年卡套餐 */ public function edit($plan_id) { $model = MemberPlanModel::detail($plan_id); $select_menu = array_column($model->toArray()['plan_access'], 'access_id'); if (request()->isGet()) { $accessModel = new AccessModel; $list = $accessModel->getList(); return $this->renderSuccess('', compact('model', 'select_menu', 'list')); } if (!$model) { return $this->renderError('套餐不存在'); } if ($model->edit($this->postData())) { return $this->renderSuccess('编辑成功'); } return $this->renderError($model->getError() ?: '编辑失败'); } /** * 删除年卡套餐 */ public function delete($plan_id) { $model = MemberPlanModel::detail($plan_id); if (!$model) { return $this->renderError('套餐不存在'); } if ($model->setDelete()) { return $this->renderSuccess('删除成功'); } return $this->renderError($model->getError() ?: '删除失败'); } }