| Current Path : /var/www/html/chatbot/backend/models/ |
| Current File : /var/www/html/chatbot/backend/models/ContentCalendarSearch.php |
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\models\ContentCalendar;
/**
* ContentCalendarSearch represents the model behind the search form of `backend\models\ContentCalendar`.
*/
class ContentCalendarSearch extends ContentCalendar
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['content_calendar_id'], 'integer'],
[['content_calendar_date', 'content_calendar_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 = ContentCalendar::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['ContentCalendarSearch']['nextmonthstart']) && !empty($params['ContentCalendarSearch']['nextmonthend'])){
$datestart = str_replace('/','-',$params['ContentCalendarSearch']['nextmonthstart']);
$dateend = str_replace('/','-',$params['ContentCalendarSearch']['nextmonthend']);
$query->andFilterWhere([
'between', 'content_calendar_date' , date('Y-m-d',strtotime($datestart)), date('Y-m-d',strtotime($dateend))
]);
}
$query->andFilterWhere(['like', 'content_calendar_description', $this->content_calendar_description])
->andFilterWhere(['like', 'created_by', $this->created_by])
->andFilterWhere(['like', 'updated_by', $this->updated_by]);
return $dataProvider;
}
}