Conditions | 4 |
Paths | 3 |
Total Lines | 15 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
16 | protected function prepareForValidation(): void |
||
17 | { |
||
18 | $data = $this->all(); |
||
19 | |||
20 | // Set roles |
||
21 | if ($data['roles'] && $this->user($this->route('guard'))->can('grant', \Cortex\Auth\Models\Ability::class)) { |
||
22 | $roles = array_map('intval', $this->get('roles', [])); |
||
23 | $data['roles'] = $this->user($this->route('guard'))->can('superadmin') ? $roles |
||
24 | : $this->user($this->route('guard'))->roles->pluck('id')->intersect($roles)->toArray(); |
||
25 | } else { |
||
26 | unset($data['roles']); |
||
27 | } |
||
28 | |||
29 | $this->replace($data); |
||
30 | } |
||
31 | |||
47 |