Exemple #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params, $currency, $transaction, $location)
 {
     $query = Exchange::find()->where(['currency' => $currency])->andWhere(['transaction' => $transaction])->andWhere(['location_id' => $location]);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'totalCount' => 100, 'pagination' => ['defaultPageSize' => 100, 'pageSizeLimit' => [1, 100]]]);
     $this->load($params);
     if (!$this->validate()) {
         $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['create_time' => $this->create_time]);
     return $dataProvider;
 }
Exemple #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getExchange()
 {
     return $this->hasMany(Exchange::className(), ['create_time' => 'date', 'location_id' => 'location_id']);
 }
Exemple #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getExchanges()
 {
     return $this->hasMany(Exchange::className(), ['user_id' => 'id']);
 }
Exemple #4
0
 /**
  * Finds the Exchange model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Exchange the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Exchange::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }