コード例 #1
0
ファイル: BudgetItemSearch.php プロジェクト: alexus007/budget
 /**
  * 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;
 }
コード例 #2
0
ファイル: BudgetSearch.php プロジェクト: alexus007/budget
 /**
  * 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;
 }
コード例 #3
0
ファイル: BudgetItem.php プロジェクト: alexus007/budget
 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()]];
 }
コード例 #4
0
ファイル: BudgetHistory.php プロジェクト: alexus007/budget
 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]];
 }