/** * Creates data provider instance with search query applied * @param array $params * @param string $email for history search * @return ActiveDataProvider */ public function search($params, $email) { $query = BounceHistory::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['time' => SORT_DESC]], 'pagination' => false]); $this->load($params); $this->email = $email; if (!$this->validate()) { return $dataProvider; } $query->andFilterWhere(['is_critical' => $this->is_critical]); $query->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'reason', $this->reason])->andFilterWhere(['like', 'status', $this->status])->andFilterWhere(['like', 'type', $this->type]); return $dataProvider; }
/** * Returns number of (soft) bounces for the given email address in {{%bounce_history}} * @param string $address email * @return int */ public function numberOfBounces($address) { return BounceHistory::find()->where(['email' => $address])->count(); }