1 | <?php |
||
2 | /** |
||
3 | * Server module for HiPanel |
||
4 | * |
||
5 | * @link https://github.com/hiqdev/hipanel-module-server |
||
6 | * @package hipanel-module-server |
||
7 | * @license BSD-3-Clause |
||
8 | * @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/) |
||
9 | */ |
||
10 | |||
11 | namespace hipanel\modules\server\models; |
||
12 | |||
13 | use yii\base\Model; |
||
14 | use yii\data\ActiveDataProvider; |
||
15 | |||
16 | /** |
||
17 | * GallerySearch represents the model behind the search form about `app\models\Gallery`. |
||
18 | */ |
||
19 | class OsimageSearch extends \hipanel\modules\server\models\Osimage |
||
20 | { |
||
21 | /** |
||
22 | * {@inheritdoc} |
||
23 | */ |
||
24 | public function rules() |
||
25 | { |
||
26 | return [ |
||
27 | [['osimage', 'livecd'], 'safe'], |
||
28 | ]; |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * {@inheritdoc} |
||
33 | */ |
||
34 | public function scenarios() |
||
35 | { |
||
36 | // bypass scenarios() implementation in the parent class |
||
37 | return Model::scenarios(); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * Creates data provider instance with search query applied. |
||
42 | * |
||
43 | * @param array $params |
||
44 | * |
||
45 | * @return ActiveDataProvider |
||
46 | */ |
||
47 | public function search($params = []) |
||
48 | { |
||
49 | $query = Server::find(); |
||
50 | |||
51 | $dataProvider = new ActiveDataProvider([ |
||
52 | 'query' => $query, |
||
53 | ]); |
||
54 | |||
55 | if (!($this->load($params) && $this->validate())) { |
||
56 | return $dataProvider; |
||
57 | } |
||
58 | |||
59 | $query->andFilterWhere([ |
||
60 | 'osimage' => $this->osimage, |
||
61 | 'livecd' => $this->livecd, |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
62 | ]); |
||
63 | |||
64 | return $dataProvider; |
||
65 | } |
||
66 | } |
||
67 |