| Conditions | 5 |
| Paths | 4 |
| Total Lines | 17 |
| 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'))->isA('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 |