/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = OrderHistory::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['create_time' => SORT_DESC]]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['record_id' => $this->record_id, 'order_id' => $this->order_id, 'model' => $this->model, 'attribute' => $this->attribute, 'record_before' => $this->record_before, 'record_after' => $this->record_after, 'create_time' => $this->create_time]);
     return $dataProvider;
 }
Exemplo n.º 2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getOrderHistory()
 {
     return $this->hasMany(OrderHistory::className(), ['order_id' => 'order_id']);
 }
 /**
  * Displays a single Order model.
  * @param integer $id
  * @return mixed
  */
 public function actionHistory($id)
 {
     $model = $this->findModel($id);
     $query = new Query();
     $orderHistory = new ActiveDataProvider(['query' => OrderHistory::find()->where(['order_id' => $model->order_id]), 'sort' => ['defaultOrder' => ['create_time' => SORT_ASC]], 'pagination' => ['pageSize' => 20]]);
     return $this->render('history', ['model' => $model, 'orderHistory' => $orderHistory, 'subData' => $this->subData]);
 }