Conditions | 5 |
Paths | 4 |
Total Lines | 17 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
16 | protected function prepareForValidation(): void |
||
17 | { |
||
18 | $data = $this->all(); |
||
19 | |||
20 | // Set roles |
||
21 | if (! empty($data['roles'])) { |
||
22 | if ($data['roles'] && $this->user($this->route('guard'))->can('grant', \Cortex\Auth\Models\Ability::class)) { |
||
|
|||
23 | $roles = array_map('intval', $this->get('roles', [])); |
||
24 | $data['roles'] = $this->user($this->route('guard'))->can('superadmin') ? $roles |
||
25 | : $this->user($this->route('guard'))->roles->pluck('id')->intersect($roles)->toArray(); |
||
26 | } else { |
||
27 | unset($data['roles']); |
||
28 | } |
||
29 | } |
||
30 | |||
31 | $this->replace($data); |
||
32 | } |
||
33 | |||
49 |
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.