Exemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = static::baseQuery();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->setSort(['defaultOrder' => ['parent_id' => SORT_ASC], 'attributes' => ['parent_id', 'currency_id', 'type_budget_item_id', 'name', 'ammount', 'date']]);
     $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, 'parent_id' => $this->parent_id, 'currency_id' => $this->currency_id, 'type_budget_item_id' => $this->type_budget_item_id, 'ammount' => $this->ammount]);
     $query->andFilterWhere(['>=', 'date', $this->date ? DateHelper::reformat($this->date) : null]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Exemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = self::baseQuery();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->setSort(['defaultOrder' => ['id' => SORT_DESC], 'attributes' => ['id', 'title', 'costs_limit', 'income_limit', 'created_date']]);
     $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, 'costs_limit' => $this->costs_limit, 'income_limit' => $this->income_limit, 'active' => $this->active]);
     $query->andFilterWhere(['>=', 'created_date', $this->created_date ? DateHelper::reformat($this->created_date) : null]);
     $query->andFilterWhere(['like', self::tableName() . '.title', $this->title]);
     return $dataProvider;
 }
Exemplo n.º 3
0
 public function behaviors()
 {
     return [['class' => TimestampBehavior::className(), 'createdAtAttribute' => 'date', 'updatedAtAttribute' => 'date', 'value' => function ($event) {
         return $this->date ? DateHelper::reformat($this->date) : null;
     }], ['class' => BlameableBehavior::className(), 'createdByAttribute' => 'user_id', 'updatedByAttribute' => false], ['class' => Tree::className(), 'titleAttribute' => 'name', 'aliasAttribute' => 'id', 'defaultCriteria' => self::baseQuery()]];
 }
Exemplo n.º 4
0
 public function behaviors()
 {
     return [['class' => TimestampBehavior::className(), 'createdAtAttribute' => 'date', 'updatedAtAttribute' => 'date', 'value' => function ($event) {
         return $this->date ? DateHelper::reformat($this->date) : DateHelper::now();
     }], ['class' => BlameableBehavior::className(), 'createdByAttribute' => 'user_id', 'updatedByAttribute' => false]];
 }