| Current Path : /var/www/html/ukas/backend/modules/ppp/models/ |
| Current File : /var/www/html/ukas/backend/modules/ppp/models/PppSearch.php |
<?php
namespace backend\modules\ppp\models;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\modules\ppp\models\Ppp;
/**
* PppSearch represents the model behind the search form of `backend\modules\ppp\models\Ppp`.
*/
class PppSearch extends Ppp {
/**
* {@inheritdoc}
*/
public function rules() {
return [
[['ppp_id', 'created_by', 'updated_by', 'ppp_type', 'ppp_name', 'ppp_sector', 'ppp_model', 'ppp_agency',
'ppp_agreement', 'ppp_location', 'ppp_details', 'ppp_img', 'created_at', 'updated_at'], 'safe'],
];
}
/**
* {@inheritdoc}
*/
public function scenarios() {
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
* @param string|null $formName Form name to be used into `->load()` method.
*
* @return ActiveDataProvider
*/
public function search($params, $formName = null) {
$query = Ppp::find();
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10,]]);
$dataProvider->setSort(['defaultOrder' => ['ppp_id' => SORT_DESC]]);
$this->load($params, $formName);
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;
}
// grid filtering conditions
$query->andFilterWhere([
'ppp_id' => $this->ppp_id,
'created_at' => $this->created_at,
'created_by' => $this->created_by,
'updated_at' => $this->updated_at,
'updated_by' => $this->updated_by,
]);
$query->andFilterWhere(['like', 'ppp_type', $this->ppp_type])
->andFilterWhere(['like', 'ppp_name', $this->ppp_name])
->andFilterWhere(['like', 'ppp_sector', $this->ppp_sector])
->andFilterWhere(['like', 'ppp_model', $this->ppp_model])
->andFilterWhere(['like', 'ppp_agency', $this->ppp_agency])
->andFilterWhere(['like', 'ppp_agreement', $this->ppp_agreement])
->andFilterWhere(['like', 'ppp_location', $this->ppp_location])
->andFilterWhere(['like', 'ppp_details', $this->ppp_details])
->andFilterWhere(['like', 'ppp_img', $this->ppp_img]);
return $dataProvider;
}
}