Example #1
0
 public function actionIndex()
 {
     if (!Yii::$app->user->isGuest && Yii::$app->user->identity->isadmin) {
         $model = new Airports();
         if ($pdata = Yii::$app->request->post('Airports')) {
             if (!empty($pdata['id'])) {
                 $model = Airports::findOne($pdata['id']);
             }
             unset($pdata['id']);
             $model->attributes = $pdata;
             $model->save();
             $this->refresh();
         }
     }
     $model = new Airports();
     return $this->render('booking', ['model' => $model]);
 }
 /**
  * Finds the Airports model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Airports the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Airports::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #3
0
 public function actionRemoveApt()
 {
     $id = Yii::$app->request->post('id');
     foreach (Flights::find()->andWhere(['airport_id' => $id])->all() as $flight) {
         $flight->delete();
     }
     $apt = Airports::findOne($id);
     $apt->delete();
 }