/**
 * Creates data provider instance with search query applied
 *
 * @param array $params
 *
 * @return ActiveDataProvider
 */
 public function search($params)
 {
     $query = Currency::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'symbol', $this->symbol])->andFilterWhere(['like', 'iso_name', $this->iso_name]);
     return $dataProvider;
 }
 /**
  * Lists all Currency models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Currency::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
示例#3
0
 public function getAllCurrenciesAsMappedArray()
 {
     $models = Currency::find()->all();
     return ArrayHelper::map($models, 'id', 'symbol');
 }
示例#4
0
 public function getDefaultCurrencyParams()
 {
     if (!($currency = Currency::find()->where(['id' => $this->default_currency_id])->andWhere(['is_active' => 1])->asArray()->one())) {
         $currency = [];
     }
     return $currency;
 }