Example #1
0
 public function actionBroker()
 {
     if (Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = Broker::findOne(Yii::$app->user->identity->getId());
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate() && $model->getDirtyAttributes()) {
             $mes = [];
             foreach ($model->getDirtyAttributes() as $k => $v) {
                 if ($k == 'name' && $model->type_id == 1) {
                     $mes[$k] = [Yii::t('app', 'Full name'), $model->name];
                 } else {
                     $mes[$k] = [$model->getAttributeLabel($k), $model->{$k}];
                 }
             }
             $message = "";
             foreach ($mes as $m) {
                 $message .= "<p><b>" . $m[0] . ":</b> " . $m[1] . "</p>";
             }
             $new = Broker::findOne($model->user_id);
             if ($message) {
                 $new->edit = $message;
                 Yii::$app->session->setFlash('success', Yii::t('app', 'Sent admin to verify.'));
             } else {
                 $new->edit = '';
             }
             $new->save();
             return $this->redirect(Url::toRoute('personal/index'));
         }
     }
     return $this->render('broker', ['model' => $model]);
 }
Example #2
0
 /**
  * Finds the Broker model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Broker the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Broker::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }