/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Mpesa::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]); $query->andFilterWhere(['like', 'origin', $this->origin])->andFilterWhere(['like', 'destination', $this->destination])->andFilterWhere(['like', 'customer_id', $this->customer_id])->andFilterWhere(['like', 'user', $this->user])->andFilterWhere(['like', 'pass', $this->pass])->andFilterWhere(['like', 'routemethod_id', $this->routemethod_id])->andFilterWhere(['like', 'routemethod_name', $this->routemethod_name])->andFilterWhere(['like', 'business_number', $this->business_number]); return $dataProvider; }
/** * Finds the Mpesa model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Mpesa the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Mpesa::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }