コード例 #1
0
 /**
  * Displays edit event page.
  *
  * @return mixed
  */
 public function actionEdit()
 {
     if (Yii::$app->request->get("eventname") == "") {
         throw new CHttpException(404, 'The specified post cannot be found.');
     }
     $eventname = Yii::$app->request->get("eventname");
     $list = Events::find()->where(['link' => $eventname]);
     if ($list->count() == 0) {
         throw new CHttpException(404, 'The specified post cannot be found.');
     }
     if ($post = Yii::$app->request->post()) {
         $trans = new Transliterate();
         $link = $trans->convert($post["name"]);
         $event = Events::find()->where(['id' => Yii::$app->request->post("id")])->one();
         $event->name = $post["name"];
         $event->geo_x = "50.4853";
         //$post["geo_x"];
         $event->geo_y = "30.5154";
         //$post["geo_y"];
         $event->geo_zoom = "21";
         //$post["geo_zoom"];
         $event->geo_name = $post["geo_name"];
         $event->geo_google_maps_link = "https://www.google.com.ua/maps/search/kiev+geo+coo...";
         //$post["geo_google_maps_link"];
         $event->desc = $post["desc"];
         $event->datetime = $post["date"] . " " . $post["time"];
         $event->full_desc = $post["full_desc"];
         $event->people_count = 0;
         $event->max_people_count = $post["max_people_count"];
         $event->image = "asdcfvgh";
         //'';
         $event->type = $post["type"];
         $event->private = Yii::$app->request->post("private") == "on" ? 1 : 0;
         $event->link = $link;
         $event->FK_organizer_id = "1";
         //'';
         $event->created = time();
         $event->updated = time();
         $event->save(false);
         $this->redirect("/events/" . $link);
     }
     return $this->render('edit', ['model' => $list->one()]);
 }
コード例 #2
0
 /**
  * Finds the Events model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @param string $sys_n
  * @return Events the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id, $sys_n)
 {
     if (($model = Events::findOne(['id' => $id, 'sys_n' => $sys_n])) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #3
0
ファイル: Users.php プロジェクト: sergpost3/hackaton
 public function getEvents()
 {
     return $this->hasOne(Events::className(), ['FK_organizer_id' => 'id']);
 }