Example #1
0
 /**
  * Deletes an existing Orders model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $order = $this->findModel($id);
     $bookingId = $order->idBooking;
     die("4");
     $booking = \app\models\Bookings::findOne($bookingId);
     $bookings_items = \app\models\Bookingitems::find()->where(['=', 'idBooking', $bookingId])->all();
     if (!empty($bookings_items)) {
         foreach ($bookings_items as $b) {
             $b->delete();
         }
     }
     $booking->delete();
     $order->delete();
     return $this->redirect(['bookings/index']);
 }
Example #2
0
 /**
  * Finds the Bookings model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Bookings the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Bookings::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public function actionDeleteBooking($booking_id)
 {
     $tour = Bookings::findOne($booking_id);
     $tour->delete();
     Yii::$app->session->setFlash('success', 'Booking successful deleted');
     return $this->redirect(['view-details-tour-date', ToursDates::FIELD_TOUR_DATE_ID => $tour->tour_date_id]);
 }