Conditions | 2 |
Paths | 1 |
Total Lines | 17 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
17 | function init() { |
||
18 | parent::init(); |
||
19 | |||
20 | $this->addFields([ |
||
21 | ['path', 'caption' => __('Page'), 'values' => HomePageSettings::getAvailableHomePages()], |
||
22 | ['role', 'caption' => __('Role'), 'enum' => Role::get()->pluck('name')->all()], |
||
23 | 'priority', |
||
24 | ]); |
||
25 | |||
26 | $this->setOrder('priority'); |
||
27 | |||
28 | $this->addHook('beforeInsert', function($model, & $data) { |
||
29 | $data['priority'] = $data['priority']?: $this->action('fx', ['max', 'priority'])->getOne() + 1; |
||
30 | }); |
||
31 | |||
32 | $this->getAction('edit')->enabled = function($model) { |
||
33 | return $model->id == 22; |
||
34 | }; |
||
37 |