Passed
Push — master ( ec9015...97207f )
by Reza
04:10
created

UserProvider   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
eloc 10
c 1
b 0
f 1
dl 0
loc 28
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A deleteAdmin() 0 5 1
A findUser() 0 3 1
A makeAdmin() 0 5 1
A getAdmins() 0 5 1
1
<?php
2
3
namespace EasyPanel\Support\User;
4
5
use App\Models\User;
0 ignored issues
show
Bug introduced by
The type App\Models\User was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
7
class UserProvider
8
{
9
10
    public function makeAdmin($id)
11
    {
12
        $user = $this->findUser($id);
13
        $user->update([
14
            config('easy_panel.column') => true
15
        ]);
16
    }
17
18
    public function getAdmins()
19
    {
20
        $users = User::query()->where(config('easy_panel.column'), true)->get();
21
22
        return $users;
23
    }
24
25
    public function findUser($id)
26
    {
27
        return config('easy_panel.user_model')::query()->findOrFail($id);
28
    }
29
30
    public function deleteAdmin($id)
31
    {
32
        $user = $this->findUser($id);
33
        $user->update([
34
            config('easy_panel.column') => false
35
        ]);
36
    }
37
38
}
39