Пример #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Reservationinfo::find()->select('reservationinfo.*')->leftJoin('objreservation', 'objreservation.id = reservationinfo.objreservation_id')->leftJoin('customers', 'objreservation.customer_id = customers.id')->leftJoin('user', 'customers.user_id = user.id')->where(['user.id' => Yii::$app->user->id]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     Yii::info($params);
     Yii::info($this->objreservation_id);
     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, 'objreservation_id' => $this->objreservation_id, 'date_begin' => $this->date_begin != "" ? strtotime($this->date_begin) : $this->date_begin, 'date_end' => $this->date_end != "" ? strtotime($this->date_end) : $this->date_end, 'qty' => $this->qty, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     return $dataProvider;
 }