/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = OrdersItem::find()->select('orders_item.*')->leftJoin('reservationinfo', 'reservationinfo.id = orders_item.reservationinfo_id')->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]); // $query = OrdersItem::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; } // grid filtering conditions $query->andFilterWhere(['id' => $this->id, 'order_id' => $this->order_id, 'reservationinfo_id' => $this->reservationinfo_id, 'price' => $this->price, 'qty_item' => $this->qty_item, 'sum_item' => $this->sum_item, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); return $dataProvider; }
public function getOrdersItem() { return $this->hasMany(OrdersItem::className(), ['reservationinfo_id' => 'id'])->viaTable('reservationinfo', ['objreservation_id' => 'id'])->viaTable('objreservation', ['customer_id' => 'id'])->viaTable('customers', ['user_id' => 'id']); }
/** * Finds the OrdersItem model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return OrdersItem the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = OrdersItem::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function getOrdersItem() { return $this->hasMany(OrdersItem::className(), ['order_id' => 'id']); }