Conditions | 4 |
Paths | 3 |
Total Lines | 38 |
Code Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
33 | public function search($params) |
||
34 | { |
||
35 | $query = Log::find(); |
||
36 | |||
37 | // add conditions that should always apply here |
||
38 | |||
39 | $dataProvider = new ActiveDataProvider([ |
||
40 | 'query' => $query, |
||
41 | 'sort'=> [ |
||
42 | 'defaultOrder' => [ |
||
43 | 'id' => SORT_DESC, |
||
44 | ], |
||
45 | ], |
||
46 | ]); |
||
47 | |||
48 | $this->load($params); |
||
49 | if (!$this->validate()) { |
||
50 | return $dataProvider; |
||
51 | } |
||
52 | // grid filtering conditions |
||
53 | $query->andFilterWhere([ |
||
54 | 'id' => $this->id, |
||
55 | 'user_ip' => $this->user_ip ? ip2long($this->user_ip) : null, |
||
56 | 'item_type' => $this->item_type, |
||
57 | 'item_id' => $this->item_id, |
||
58 | 'action' => $this->action, |
||
59 | 'user' => $this->user, |
||
60 | ]); |
||
61 | if ($this->log_date) { |
||
62 | $query->andFilterWhere([ |
||
63 | 'BETWEEN', |
||
64 | 'log_date', |
||
65 | strtotime($this->log_date . ' 00:00:00'), |
||
66 | strtotime($this->log_date . ' 23:59:59'), |
||
67 | ]); |
||
68 | } |
||
69 | |||
70 | return $dataProvider; |
||
71 | } |
||
73 |