コード例 #1
0
ファイル: AdminController.php プロジェクト: kilinanatoly/zkam
 public function actionCreate_city($id)
 {
     @session_start();
     $_SESSION['menu'] = 2;
     $functions_model = new Functions();
     $model = new GeobaseCity();
     if ($model->load(Yii::$app->request->post())) {
         if (empty($model->url)) {
             $model->url = $functions_model->translit($model->name);
         }
         if (!empty($model->name)) {
             $model->region_id = $id;
             if ($model->validate()) {
                 if ($model->save()) {
                     $session = new Session();
                     $session->open();
                     $session = Yii::$app->session;
                     $session->setFlash('add_city', '<div class="alert alert-success">Вы успешно добавили город.</div>');
                     return $this->redirect('create_city?id=' . $id);
                 }
             }
         }
     }
     $region = GeobaseRegion::findOne(['id' => $id]);
     return $this->render('edit_city', ['model' => $model, 'region' => $region]);
 }