コード例 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = UserLocations::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'loc_id' => $this->loc_id]);
     $query->andFilterWhere(['like', 'ime', $this->ime]);
     return $dataProvider;
 }
コード例 #2
0
ファイル: Locations.php プロジェクト: bokko79/servicemapp
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUserLocations()
 {
     return $this->hasMany(UserLocations::className(), ['loc_id' => 'id']);
 }
コード例 #3
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;
     }
 }
コード例 #4
0
 /**
  * Finds the UserLocations model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return UserLocations the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = UserLocations::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }