/** * Reply an existing Mensagens model. * If reply is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionReply($id) { $original = $this->findModel($id); $model = new Mensagens(); $model->assunto = $original->assunto; $model->resposta_de = $original->id_mensagem; $model->id_destinatario = $original->criado_por; $model->criado_por = Yii::$app->user->getId(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id_mensagem]); } else { return $this->render('reply', ['model' => $model]); } }