Passed
Push — dev6 ( d58043...568a9a )
by Ron
17:54
created

UserPolicy::delete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 0
c 2
b 0
f 0
dl 0
loc 2
ccs 0
cts 0
cp 0
rs 10
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
namespace App\Policies;
4
5
use App\Models\User;
6
use App\Traits\AllowTrait;
7
use Illuminate\Auth\Access\HandlesAuthorization;
8
use Illuminate\Auth\Access\Response;
9
10
class UserPolicy
11
{
12
    use HandlesAuthorization;
13
    use AllowTrait;
1 ignored issue
show
introduced by
The trait App\Traits\AllowTrait requires some properties which are not provided by App\Policies\UserPolicy: $role_id, $username, $allow
Loading history...
14
15
    /**
16
     * Determine whether the user can view any models.
17 22
     *
18
     * @param  \App\Models\User  $user
19 22
     * @return \Illuminate\Auth\Access\Response|bool
20
     */
21 22
    public function viewAny(User $user)
0 ignored issues
show
Unused Code introduced by
The parameter $user is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

21
    public function viewAny(/** @scrutinizer ignore-unused */ User $user)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
22 22
    {
23
        //
24 22
    }
25
26 22
    /**
27
     * Determine whether the user can view the model.
28 11
     *
29
     * @param  \App\Models\User  $user
30 11
     * @param  \App\Models\User  $model
31
     * @return \Illuminate\Auth\Access\Response|bool
32
     */
33
    public function view(User $user, User $model)
0 ignored issues
show
Unused Code introduced by
The parameter $model is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

33
    public function view(User $user, /** @scrutinizer ignore-unused */ User $model)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $user is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

33
    public function view(/** @scrutinizer ignore-unused */ User $user, User $model)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
34
    {
35
        //
36
    }
37
38
    /**
39
     * Determine whether the user can create models.
40
     *
41
     * @param  \App\Models\User  $user
42
     * @return \Illuminate\Auth\Access\Response|bool
43 4
     */
44
    public function create(User $user)
0 ignored issues
show
Unused Code introduced by
The parameter $user is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

44
    public function create(/** @scrutinizer ignore-unused */ User $user)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
45 4
    {
46
        //
47
    }
48
49
    /**
50
     * Determine whether the user can update the user profile
51 6
     */
52
    public function update(User $user, User $model)
53 6
    {
54
        if($this->checkPermission($user, 'Manage Users'))
55
        {
56
            //  If they user has permission to Manage Users, they cannot manage anyone with a higher role than themselves
57
            if($user->role_id < $model->role_id)
58
            {
59
                return Response::deny('You cannot modify a user with higher permissions than yourself');
60
            }
61
62
            return true;
63
        }
64
65
        return $user->user_id === $model->user_id;
66
    }
67 1
68
    /**
69 1
     * Determine whether the user can delete the model.
70
     *
71
     * @param  \App\Models\User  $user
72
     * @param  \App\Models\User  $model
73
     * @return \Illuminate\Auth\Access\Response|bool
74
     */
75
    public function delete(User $user, User $model)
0 ignored issues
show
Unused Code introduced by
The parameter $user is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

75
    public function delete(/** @scrutinizer ignore-unused */ User $user, User $model)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $model is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

75
    public function delete(User $user, /** @scrutinizer ignore-unused */ User $model)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
76
    {
77
        //
78
    }
79
80
    /**
81
     * Determine whether the user can restore the model.
82
     *
83
     * @param  \App\Models\User  $user
84
     * @param  \App\Models\User  $model
85
     * @return \Illuminate\Auth\Access\Response|bool
86
     */
87
    public function restore(User $user, User $model)
0 ignored issues
show
Unused Code introduced by
The parameter $model is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

87
    public function restore(User $user, /** @scrutinizer ignore-unused */ User $model)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $user is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

87
    public function restore(/** @scrutinizer ignore-unused */ User $user, User $model)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
88
    {
89
        //
90
    }
91
92
    /**
93
     * Determine whether the user can permanently delete the model.
94
     *
95
     * @param  \App\Models\User  $user
96
     * @param  \App\Models\User  $model
97
     * @return \Illuminate\Auth\Access\Response|bool
98
     */
99
    public function forceDelete(User $user, User $model)
0 ignored issues
show
Unused Code introduced by
The parameter $model is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

99
    public function forceDelete(User $user, /** @scrutinizer ignore-unused */ User $model)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $user is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

99
    public function forceDelete(/** @scrutinizer ignore-unused */ User $user, User $model)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
100
    {
101
        //
102
    }
103
}
104