frontend\modules\topic\controllers\DefaultController::actionUpdate PHP Method

actionUpdate() public method

修改自己的话题
public actionUpdate ( integer $id ) : string | Response
$id integer
return string | yii\web\Response
    public function actionUpdate($id)
    {
        $model = Topic::findTopic($id);
        if (!($model && (User::getThrones() || $model->isCurrent()))) {
            throw new NotFoundHttpException();
        }
        if ($model->load(Yii::$app->request->post()) && $model->validate()) {
            if ($model->save()) {
                $this->flash('发表更新成功!', 'success');
                return $this->redirect(['view', 'id' => $model->id]);
            }
        } else {
            return $this->render('update', ['model' => $model]);
        }
    }