Guest User

Untitled

a guest
Dec 15th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. <?php
  2.  
  3. namespace backendmodelssearch;
  4.  
  5. use Yii;
  6. use yiibaseModel;
  7. use yiidataActiveDataProvider;
  8. use commonmodelsTruck;
  9.  
  10. /**
  11. * ArticleSearch represents the model behind the search form about `commonmodelsArticle`.
  12. */
  13. class TruckSearch extends Truck
  14. {
  15. /**
  16. * @inheritdoc
  17. */
  18. public function rules()
  19. {
  20. return [
  21. [['id'], 'integer'],
  22. [['id', 'type_id', 'name', 'carrying'], 'safe'],
  23. ];
  24. }
  25.  
  26. /**
  27. * @inheritdoc
  28. */
  29. public function scenarios()
  30. {
  31. // bypass scenarios() implementation in the parent class
  32. return Model::scenarios();
  33. }
  34.  
  35. /**
  36. * Creates data provider instance with search query applied
  37. * @return ActiveDataProvider
  38. */
  39. public function search($params)
  40. {
  41. $query = Truck::find();
  42.  
  43. $dataProvider = new ActiveDataProvider([
  44. 'query' => $query,
  45. ]);
  46.  
  47. if (!($this->load($params) && $this->validate())) {
  48. return $dataProvider;
  49. }
  50.  
  51. $query->andFilterWhere([
  52. 'id' => $this->id,
  53. 'type_id' => $this->type_id,
  54. 'name' => $this->name,
  55. 'carrying' => $this->carrying,
  56. 'status' => $this->status,
  57. ]);
  58.  
  59. /*$query->andFilterWhere(['like', 'slug', $this->slug])
  60. ->andFilterWhere(['like', 'title', $this->title])
  61. ->andFilterWhere(['like', 'body', $this->body]);*/
  62.  
  63. return $dataProvider;
  64. }
  65. }
Add Comment
Please, Sign In to add comment