| Current Path : /var/www/html/chatbot/backend/models/ |
| Current File : /var/www/html/chatbot/backend/models/BanciVideoSearch.php |
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\models\BanciVideo;
/**
* BanciVideoSearch represents the model behind the search form of `backend\models\BanciVideo`.
*/
class BanciVideoSearch extends BanciVideo
{
public $year;
public $month;
/**
* @inheritdoc
*/
public function rules()
{
return [
[['video_id', 'video_status'], 'integer'],
[['video_title', 'video_title_en', 'video_description', 'video_description_en', '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 = BanciVideo::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
$query->andFilterWhere([
'video_id' => $this->video_id,
'video_status' => $this->video_status,
// 'created_at' => $this->created_at,
// 'updated_at' => $this->updated_at,
]);
if (!empty($this->year)) {
$query->andFilterWhere(['YEAR(created_at)' => $this->year]);
}
if (!empty($this->month)) {
$query->andFilterWhere(['MONTH(created_at)' => $this->month]);
}
if (!empty($this->banci_article_status)) {
$query->andFilterWhere(['video_status' => $this->banci_article_status]);
}
$query->andFilterWhere(['like', 'video_title', $this->video_title])
->andFilterWhere(['like', 'video_title_en', $this->video_title_en])
->andFilterWhere(['like', 'video_description', $this->video_description])
->andFilterWhere(['like', 'video_description_en', $this->video_description_en])
->andFilterWhere(['like', 'created_by', $this->created_by])
->andFilterWhere(['like', 'updated_by', $this->updated_by]);
return $dataProvider;
}
}