HelpVideoSearch.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace app\models;
  3. use Yii;
  4. use yii\base\Model;
  5. use yii\data\ActiveDataProvider;
  6. use app\models\HelpVideo;
  7. /**
  8. * HelpVideoSearch represents the model behind the search form about `app\models\HelpVideo`.
  9. */
  10. class HelpVideoSearch extends HelpVideo
  11. {
  12. /**
  13. * @inheritdoc
  14. */
  15. public function rules()
  16. {
  17. return [
  18. [['id', 'cat_id', 'created_at'], 'integer'],
  19. [['link'], 'safe'],
  20. ];
  21. }
  22. /**
  23. * @inheritdoc
  24. */
  25. public function scenarios()
  26. {
  27. // bypass scenarios() implementation in the parent class
  28. return Model::scenarios();
  29. }
  30. /**
  31. * Creates data provider instance with search query applied
  32. *
  33. * @param array $params
  34. *
  35. * @return ActiveDataProvider
  36. */
  37. public function search($params)
  38. {
  39. $query = HelpVideo::find();
  40. // add conditions that should always apply here
  41. $dataProvider = new ActiveDataProvider([
  42. 'query' => $query,
  43. ]);
  44. $this->load($params);
  45. if (!$this->validate()) {
  46. // uncomment the following line if you do not want to return any records when validation fails
  47. // $query->where('0=1');
  48. return $dataProvider;
  49. }
  50. // grid filtering conditions
  51. $query->andFilterWhere([
  52. 'id' => $this->id,
  53. 'cat_id' => $this->cat_id,
  54. 'created_at' => $this->created_at,
  55. ]);
  56. $query->andFilterWhere(['like', 'link', $this->link]);
  57. return $dataProvider;
  58. }
  59. }