Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = FieldList::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'visibility' => $this->visibility, 'new' => $this->new, 'excluded' => $this->excluded, 'inserted_at' => $this->inserted_at]);
     $query->andFilterWhere(['like', 'field', $this->field])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
Example #2
0
 public static function renewMultipleFields($fields)
 {
     $time = new Expression("NOW()");
     $data = 0;
     foreach ($fields as $value) {
         $record = FieldList::find()->where(['field' => $value])->one();
         if ($record) {
             $record->excluded = 0;
             $record->excluded_at = null;
             $record->renewed_at = $time;
             $record->new = 0;
             $record->update();
             $data = $data + 1;
         }
     }
     //        return $data;
     return FieldList::find()->orderBy(['field' => SORT_ASC])->asArray()->all();
 }