/**
  * Creates a new UserLocations model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new UserLocations();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Esempio n. 2
0
 protected function saveOrderEndLocation($model, $location_end, $service)
 {
     if ($model->loc_id2 == null && ($service->location == 2 || $service->location == 4)) {
         if ($location_end->load(Yii::$app->request->post())) {
             $location_end->user_id = Yii::$app->user->id;
             if ($location_end->save()) {
                 $model->loc_id2 = $location_end->id;
                 $user_location2 = new UserLocations();
                 $user_location2->loc_id = $location_end->id;
                 $user_location2->user_id = Yii::$app->user->id;
                 $user_location2->save();
             }
         }
         /*if($service->location==2 && ($model->loc_id==null || $model->loc_id2==null))){                        
                   return $this->redirect('/new-order'); // redirect back
           }*/
     } else {
         return false;
     }
 }