/** * Creates a new Message model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate($id) { $model = new Message(); $model->recipient_id = $id; $model->sender_id = Yii::$app->user->id; if ($model->load(Yii::$app->request->post()) && $model->save()) { } return $this->renderAjax('create', ['model' => $model]); }
/** * Creates a new Message model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Message(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new Message model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Message(); if ($model->load(Yii::$app->request->post()) && $model->save()) { Yii::$app->session->setFlash('success', '留言提交成功,我们会尽快回复'); return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new Message model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Message(); $model->status = 1; if ($model->load(Yii::$app->request->post()) && $model->save()) { Yii::$app->getSession()->setFlash('message-create-success'); return $this->redirect(['index']); } else { return $this->render('create', ['model' => $model]); } }
public function actionCreate() { $model = new Message(); $parseData['model'] = $model; $parseData['sensors'] = $this->getSensor(); $post = Yii::$app->request->post(); if (!empty($post)) { $model->load($post); $model->save(); return $this->redirect(['index']); } return $this->render('create', $parseData); }
/** * 发送小纸条数据 * @return string|\yii\web\Response */ public function actionSend() { $model = new Message(); if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) { Yii::$app->response->format = Response::FORMAT_JSON; return ActiveForm::validate($model); } if ($model->load(Yii::$app->request->post())) { $model->send_id = Yii::$app->user->id; if ($model->save()) { Yii::$app->getSession()->setFlash('success', '发送成功'); } else { Yii::$app->getSession()->setFlash('success', '发送失败'); } } return $this->render('send', ['model' => $model]); }