/var/www/vhosts/nabawater/backend/models
Edit: /var/www/vhosts/nabawater/backend/models/IngredientSearch.php (2353B)
alias('I')
->select('I.*')
->where(['<>', 'I.ingredient_status', Ingredient::DELETE]);
if (AdminUser::isVendor()) {
$query->andWhere(['I.vendor_id' => Yii::$app->getUser()->getIdentity()->vendor_id]);
}
if (AdminUser::isBranch()) {
$query->andWhere(['I.vendor_id' => Yii::$app->getUser()->getIdentity()->vendor_id]);
}
Ingredient::selectTranslation($query);
Vendor::selectTranslation($query,'I',null,'VL');
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => [
'PageSize' => Com::postPerPage(),
],
'sort' => [
'attributes' => [
'ingredient_id',
'ingredient_name',
'sort_no'
],
'defaultOrder' => [
'ingredient_id' => SORT_DESC,
'ingredient_name' => SORT_DESC,
'sort_no' => SORT_DESC
]
]
]);
$this->load($params);
if(!$this->validate()) {
return $dataProvider;
}
$query->andFilterWhere(['like', 'IL.ingredient_name', strtolower($this->ingredient_name)])
->andFilterWhere(['like', 'I.sort_no', $this->sort_no])
->andFilterWhere(['like', 'I.ingredient_status', $this->ingredient_status])
->andFilterWhere(['like', 'I.ingredient_type', $this->ingredient_type])
->andFilterWhere(['like', 'I.vendor_id', $this->vendor_name]);
return $dataProvider;
}
}