| Current Path : /var/www/html/mtdc/backend/models/networking/ |
| Current File : /var/www/html/mtdc/backend/models/networking/NetworkingBusinessCardSearch.php |
<?php
namespace backend\models\networking;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\models\networking\NetworkingBusinessCard;
/**
* NetworkingBusinessCardSearch represents the model behind the search form of `backend\models\networking\NetworkingBusinessCard`.
*/
class NetworkingBusinessCardSearch extends NetworkingBusinessCard {
/**
* {@inheritdoc}
*/
public function rules() {
return [
[['id', 'company_id', 'created_by', 'updated_by'], 'integer'],
[['user_fullname', 'user_designation', 'user_designation_my', 'user_department', 'user_department_my',
'user_mobile_no', 'company_category', 'company_country', 'company_email', 'company_address',
'company_state', 'company_tel', 'company_fax', 'company_website', 'card_front_img', 'card_front_back', '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
*
* @return ActiveDataProvider
*/
public function search($params) {
$query = NetworkingBusinessCard::find();
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 100,]]);
$dataProvider->setSort(['defaultOrder' => ['updated_at' => SORT_DESC]]);
$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(['like', 'user_fullname', $this->user_fullname]);
$query->andFilterWhere(['OR', ['like', 'user_designation', $this->user_designation], ['like', 'user_designation_my', $this->user_designation]]);
$query->andFilterWhere(['OR', ['like', 'user_department', $this->user_department], ['like', 'user_department_my', $this->user_department]]);
$query->andFilterWhere(['=', 'company_category', $this->company_category]);
$query->andFilterWhere(['=', 'company_id', $this->company_id]);
return $dataProvider;
}
}