attributes = $param; $form->store_id = get_store_id(); return $this->asJson($form->search()); } /** * 获取详情 */ public function actionInfo($id = null) { return $this->asJson([ 'code' => 0, 'data' => [ 'model' => QAndACat::findOne($id) ] ]); } /** * 保存 */ public function actionSave() { $form = new CatForm(); $form->attributes = post_params(); return $this->asJson($form->save()); } public function actionState($id = null, $state = 1) { $id = json_decode($id, true); foreach ($id as $v) { $model = QAndACat::findOne($v); if (!$model) { return $this->asJson([ 'code' => 1, 'msg' => '请刷新重试' ]); } $model->state = $state; $model->save(); } return $this->asJson([ 'code' => 0, 'msg' => '成功' ]); } /** * 删除 * @param $id */ public function actionDel($id) { $model = QAndACat::findOne($id); if (empty($model)) { $res = ['code' => 1, 'msg' => '参数错误']; } else { $model->is_delete = 1; $res = $model->save() ? ['code' => 0, 'msg' => '保存成功'] : ['code' => 1, 'msg' => '保存失败']; } return $this->asJson($res); } }