Exemplo n.º 1
0
 public function getCharacteristics()
 {
     return $this->hasOne(Characteristics::className(), ['id' => $this->parent_id]);
 }
Exemplo n.º 2
0
 public function actionArendatypes()
 {
     @session_start();
     $_SESSION['menu'] = 4;
     $model = new ArendaTypes();
     if ($model->load(Yii::$app->request->post())) {
         $translit_model = new Functions();
         $model->url = $translit_model->translit($model->name);
         if ($model->validate()) {
             if ($model->save()) {
                 $session = Yii::$app->session;
                 $session->setFlash('add', '<div class="alert alert-success">Вы успешно добавили тип аренды.</div>');
                 return $this->redirect(array('arendatypes'));
             }
         }
     }
     if (Yii::$app->request->post('delete_character')) {
         $del_items = Yii::$app->request->post('delete_character');
         foreach ($del_items as $key => $value) {
             $character = Characteristics::findOne(['id' => $key]);
             $character->delete();
         }
     }
     //получаем список типов аренды
     $arenda_types = $model->find()->asArray()->all();
     return $this->render('arenda_types', ['model' => $model, 'data' => $arenda_types]);
 }