| Current Path : /var/www/html/ekursus/backend/models/ |
| Current File : /var/www/html/ekursus/backend/models/BanciNextMonthSearch.php |
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\models\BanciNextMonth;
/**
* BanciNextMonthSearch represents the model behind the search form of `backend\models\BanciNextMonth`.
*/
class BanciNextMonthSearch extends BanciNextMonth
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['banci_next_month_id'], 'integer'],
[['banci_next_month_date', 'banci_next_month_description', 'created_at', 'created_by', 'updated_at', 'updated_by'], '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 = BanciNextMonth::find();
// add conditions that should always apply here
$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;
}
// grid filtering conditions
if(!empty($params['BanciNextMonthSearch']['nextmonthstart']) && !empty($params['BanciNextMonthSearch']['nextmonthend'])){
$datestart = str_replace('/','-',$params['BanciNextMonthSearch']['nextmonthstart']);
$dateend = str_replace('/','-',$params['BanciNextMonthSearch']['nextmonthend']);
$query->andFilterWhere([
'between', 'banci_next_month_date' , date('Y-m-d',strtotime($datestart)), date('Y-m-d',strtotime($dateend))
]);
}
$query->andFilterWhere(['like', 'banci_next_month_description', $this->banci_next_month_description])
->andFilterWhere(['like', 'created_by', $this->created_by])
->andFilterWhere(['like', 'updated_by', $this->updated_by]);
return $dataProvider;
}
}