1 | <?php |
||
2 | |||
3 | namespace App\Services; |
||
4 | |||
5 | use App\Models\User; |
||
6 | |||
7 | class UserServices |
||
8 | { |
||
9 | /** |
||
10 | * Gets the user. |
||
11 | * |
||
12 | * @param int $userId The user identifier |
||
13 | * |
||
14 | * @return collection The user. |
||
0 ignored issues
–
show
|
|||
15 | */ |
||
16 | public static function getUser($userId) |
||
17 | { |
||
18 | return User::findOrFail($userId); |
||
19 | } |
||
20 | |||
21 | /** |
||
22 | * Check is user is admin or super admin. |
||
23 | * |
||
24 | * @param int $userId The user identifier |
||
25 | */ |
||
26 | public static function checkIsUserAdminOrHigher($userId) |
||
27 | { |
||
28 | $user = self::getUser($userId); |
||
29 | if (!$user->hasRole(['admin', 'super.admin'])) { |
||
30 | abort(401); |
||
31 | } |
||
32 | } |
||
33 | } |
||
34 |
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