$searchModel = new CustomersSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
In Yii2, by default, we are provided with a searchModel and a dataProvider for the Index action. However, to customize the data returned so that it meets a specific criteria, I get a challenge. This is what I did:
$searchModel = new CustomersSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$dataProvider->query->where('customers.status = 10');
This works fine but the problem is it interferes with the filterModel of the GridView such that searching anything from the provided search filters does not work on the data returned by the GridView. Is there a where in which I can add conditions to the searchModel without affecting the filterModel in the GridView?