service = new ReportService(['mall_id' => $this->mall_id]); return $action; } /** * 提交举报 * * @return string */ public function actionSubmit(int $id, string $from) { $post = $this->request->post(); $validate = Yii::$app->services->validate->validate($post, [ [['type', 'content'], 'required'], ]); if (!$validate) return $this->error(Yii::$app->services->validate->getErrorMessage()); return $this->service->addReport($id, $from, $post) ? $this->success('举报成功') : $this->error($this->service->getError()); } }