public function saveToMessage() { $message = new Messages(); $message->loadDefaultValues(); $message->from = Yii::$app->user->identity->id; $message->user_id = $this->invitee->id; $message->messageType = 1; $message->save(); $message->content = Yii::$app->controller->renderPartial('_invite_message', ['code' => $this->codeBank_code, 'username' => $this->invitee->username, 'role' => $this->auth_item_name, 'user_id' => $message->user_id, 'message_id' => $message->id]); return $message->save(); }
/** * Creates a new Messages model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Messages(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Displays contact page. * * @return mixed */ public function actionContact() { $model = new Messages(); if ($model->load(Yii::$app->request->post()) && $model->save()) { Yii::$app->session->setFlash('success', 'Спасибо за то что связались с нами'); return $this->refresh(); } else { return $this->render('contact', ['model' => $model]); } }