public function actionNewPost() { $this->checkIsGuest(); $data = $this->getPostValue('Post'); $threadId = $data['thread_id']; $post = new Post(); $post->thread_id = $threadId; $post->user_id = $this->identity->id; $post->user_name = $this->identity->username; $post->title = isset($data['title']) ? $data['title'] : ''; $post->body = $data['body']; $post->create_time = $this->getCurrentTime(); $post->modify_time = $this->getCurrentTime(); $post->supports = 0; $post->againsts = 0; $post->floor = 0; $post->note = ''; if ($post->save()) { Thread::updateAllCounters(['posts' => 1], ['id' => $threadId]); } return $this->redirect(['view', 'id' => $post->thread_id]); }