/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Orders::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, 'price' => $this->price, 'date_order' => $this->date_order]); $query->andFilterWhere(['like', 'delivery', $this->delivery])->andFilterWhere(['like', 'product_ids', $this->product_ids])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'adress', $this->adress])->andFilterWhere(['like', 'notice', $this->notice])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'phone', $this->phone]); return $dataProvider; }
public function actionOrders() { $query = Orders::find()->joinWith(['customer', 'orderProducts.product.images', 'orderProducts.product.characteristics']); $model = $query->all(); return $this->render('orders', ['model' => $model]); }