92 lines
2.7 KiB
PHP
92 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace app\models;
|
|
|
|
use Yii;
|
|
use yii\base\Model;
|
|
use yii\data\ActiveDataProvider;
|
|
use app\models\Schedule;
|
|
|
|
/**
|
|
* ScheduleSearch represents the model behind the search form of `app\models\Schedule`.
|
|
*/
|
|
class ScheduleSearch extends Schedule {
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function rules() {
|
|
return [
|
|
[['id', 'SunTime1', 'SunTime2', 'SunTime3', 'MonTime1', 'MonTime2', 'MonTime3', 'TueTime1', 'TueTime2', 'TueTime3', 'WedTime1', 'WedTime2', 'WedTime3', 'ThuTime1', 'ThuTime2', 'ThuTime3', 'FriTime1', 'FriTime2', 'FriTime3', 'SatTime1', 'SatTime2', 'SatTime3'], 'integer'],
|
|
[['name', 'description'], '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 = Schedule::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([
|
|
'id' => $this->id,
|
|
'SunTime1' => $this->SunTime1,
|
|
'SunTime2' => $this->SunTime2,
|
|
'SunTime3' => $this->SunTime3,
|
|
'MonTime1' => $this->MonTime1,
|
|
'MonTime2' => $this->MonTime2,
|
|
'MonTime3' => $this->MonTime3,
|
|
'TueTime1' => $this->TueTime1,
|
|
'TueTime2' => $this->TueTime2,
|
|
'TueTime3' => $this->TueTime3,
|
|
'WedTime1' => $this->WedTime1,
|
|
'WedTime2' => $this->WedTime2,
|
|
'WedTime3' => $this->WedTime3,
|
|
'ThuTime1' => $this->ThuTime1,
|
|
'ThuTime2' => $this->ThuTime2,
|
|
'ThuTime3' => $this->ThuTime3,
|
|
'FriTime1' => $this->FriTime1,
|
|
'FriTime2' => $this->FriTime2,
|
|
'FriTime3' => $this->FriTime3,
|
|
'SatTime1' => $this->SatTime1,
|
|
'SatTime2' => $this->SatTime2,
|
|
'SatTime3' => $this->SatTime3,
|
|
'created_at' => $this->created_at,
|
|
'modified_at' => $this->modified_at,
|
|
]);
|
|
|
|
$query->andFilterWhere(['like', 'name', $this->name])
|
|
->andFilterWhere(['like', 'description', $this->description]);
|
|
|
|
return $dataProvider;
|
|
}
|
|
|
|
}
|