| Total Complexity | 9 |
| Total Lines | 64 |
| Duplicated Lines | 0 % |
| Changes | 8 | ||
| Bugs | 0 | Features | 2 |
| 1 | <?php |
||
| 8 | class UserProvider |
||
| 9 | { |
||
| 10 | |||
| 11 | public function makeAdmin($id, $is_super = false) |
||
| 12 | { |
||
| 13 | $user = $this->findUser($id); |
||
| 14 | |||
| 15 | if ($user->panelAdmin()->exists()){ |
||
| 16 | return [ |
||
| 17 | 'type' => 'error', |
||
| 18 | 'message' => 'User already is an admin!' |
||
| 19 | ]; |
||
| 20 | } |
||
| 21 | |||
| 22 | $user->panelAdmin()->create([ |
||
| 23 | 'is_superuser' => $is_super, |
||
| 24 | ]); |
||
| 25 | |||
| 26 | if($is_super) |
||
| 27 | $this->makeSuperAdminRole($user); |
||
| 28 | |||
| 29 | return [ |
||
| 30 | 'type' => 'success', |
||
| 31 | 'message' => "User '$id' was converted to an admin", |
||
| 32 | ]; |
||
| 33 | } |
||
| 34 | |||
| 35 | public function getAdmins() |
||
| 36 | { |
||
| 37 | return $this->getUserModel()::query()->whereHas('panelAdmin')->with('panelAdmin')->get(); |
||
| 38 | } |
||
| 39 | |||
| 40 | public function paginateAdmins($perPage = 20) |
||
| 41 | { |
||
| 42 | return $this->getUserModel()::query()->whereHas('panelAdmin')->with('panelAdmin')->paginate($perPage); |
||
| 43 | } |
||
| 44 | |||
| 45 | public function findUser($id) |
||
| 46 | { |
||
| 47 | return $this->getUserModel()::query()->findOrFail($id); |
||
| 48 | } |
||
| 49 | |||
| 50 | public function deleteAdmin($id) |
||
| 55 | } |
||
| 56 | |||
| 57 | private function getUserModel() |
||
| 58 | { |
||
| 60 | } |
||
| 61 | |||
| 62 | private function makeSuperAdminRole($user) |
||
| 72 | } |
||
| 73 | |||
| 75 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths