frontend\modules\tweet\controllers\DefaultController::actionCreate PHP Method

actionCreate() public method

新建动弹
public actionCreate ( ) : mixed
return mixed
    public function actionCreate()
    {
        $model = new Tweet();
        if ($model->load(Yii::$app->request->post()) && $model->validate()) {
            $topService = new TweetService();
            if (!$topService->filterContent($model->content)) {
                $this->flash('请勿发表无意义的内容', 'warning');
                return $this->redirect('index');
            }
            $model->user_id = Yii::$app->user->id;
            $model->type = $model::TYPE;
            if ($model->save()) {
                $this->flash('发表成功!', 'success');
            }
        }
        return $this->redirect('index');
    }