pmtpenza

Untitled

Jul 30th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. <?php
  2.  
  3. namespace backend\models;
  4.  
  5. use yii\base\Model;
  6. use yii\data\ActiveDataProvider;
  7. use backend\models\Deals;
  8.  
  9. /**
  10. * DealsSearch represents the model behind the search form of `backend\models\Deals`.
  11. */
  12. class DealsSearch extends Deals
  13. {
  14. public $sum;
  15. /**
  16. * {@inheritdoc}
  17. */
  18. public function rules()
  19. {
  20. return [
  21. [['id', 'user_id', 'staussdelki_id','client_id', 'sum'], 'integer'],
  22. [['budget', 'tz', 'date', 'notes', 'doc', 'payment', 'paymentdate', 'finch_date'], '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. *
  38. * @param array $params
  39. *
  40. * @return ActiveDataProvider
  41. */
  42. public function search($params)
  43. {
  44. $query = Deals::find();
  45. $query->joinWith(['client']);
  46.  
  47.  
  48. // add conditions that should always apply here
  49.  
  50. $dataProvider = new ActiveDataProvider([
  51. 'query' => $query,
  52.  
  53. ]);
  54.  
  55. $this->load($params);
  56.  
  57. if (!$this->validate()) {
  58. // uncomment the following line if you do not want to return any records when validation fails
  59. // $query->where('0=1');
  60. return $dataProvider;
  61. }
  62.  
  63. // grid filtering conditions
  64. $query->andFilterWhere([
  65. 'id' => $this->id,
  66. 'user_id' => $this->user_id,
  67. 'staussdelki_id' => $this->staussdelki_id,
  68. 'sum' => $this->sum,
  69. 'finch_date' => $this->finch_date,
  70. ]);
  71.  
  72. $query
  73. ->andFilterWhere(['like', 'budget', $this->budget])
  74. ->andFilterWhere(['like', 'tz_doc', $this->tz_doc])
  75. ->andFilterWhere(['like', 'tz_text', $this->tz_text])
  76. ->andFilterWhere(['like', 'date', $this->date])
  77. ->andFilterWhere(['like', 'client_id', $this->date])
  78. ->andFilterWhere(['like', 'notes', $this->notes])
  79. ->andFilterWhere(['like', 'doc', $this->doc])
  80. ->andFilterWhere(['like', 'payment', $this->payment])
  81. ->andFilterWhere(['like', 'paymentdate', $this->paymentdate])
  82. ->andFilterWhere(['like', 'sum', $this->sum])
  83. ->andFilterWhere(['like', 'finch_date', $this->finch_date]);
  84.  
  85. return $dataProvider;
  86. }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment