Test Setup Failed
Push — dev6 ( 81193f...01d104 )
by Ron
22:34
created

EquipmentCategoryPolicy::viewAny()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace App\Policies;
4
5
use App\Models\EquipmentCategory;
6
use App\Models\User;
7
use App\Models\UserRolePermissions;
8
use Illuminate\Auth\Access\HandlesAuthorization;
9
use Illuminate\Support\Facades\Log;
10
11
class EquipmentCategoryPolicy
12
{
13
    use HandlesAuthorization;
14
15
    /*
16
    *   Allow anyone with "Manage Equipment" permission
17
    */
18
    public function before(User $user, $method)
19
    {
20
        $allowed = UserRolePermissions::whereRoleId($user->role_id)->whereHas('UserRolePermissionTypes', function($q)
21
        {
22
            $q->where('description', 'Manage Equipment');
23
        })->first();
24
25
        Log::channel('auth')->debug('User '.$user->username.' is checking User Policy access to '.$method.'.  Result - '.($allowed->allow ? 'Allow' : 'Deny'));
26
27
        if($allowed->allow)
28
        {
29
            return $allowed->allow;
30
        }
31
    }
32
33
    /**
34
     * Determine whether the user can view any models.
35
     *
36
     * @param  \App\Models\User  $user
37
     * @return mixed
38
     */
39
    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

39
    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...
40
    {
41
        return false;
42
    }
43
44
    /**
45
     * Determine whether the user can view the model.
46
     *
47
     * @param  \App\Models\User  $user
48
     * @param  \App\Models\EquipmentCategory  $equipmentCategory
49
     * @return mixed
50
     */
51
    public function view(User $user, EquipmentCategory $equipmentCategory)
0 ignored issues
show
Unused Code introduced by
The parameter $equipmentCategory 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

51
    public function view(User $user, /** @scrutinizer ignore-unused */ EquipmentCategory $equipmentCategory)

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

51
    public function view(/** @scrutinizer ignore-unused */ User $user, EquipmentCategory $equipmentCategory)

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...
52
    {
53
        return false;
54
    }
55
56
    /**
57
     * Determine whether the user can create models.
58
     *
59
     * @param  \App\Models\User  $user
60
     * @return mixed
61
     */
62
    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

62
    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...
63
    {
64
        return false;
65
    }
66
67
    /**
68
     * Determine whether the user can update the model.
69
     *
70
     * @param  \App\Models\User  $user
71
     * @param  \App\Models\EquipmentCategory  $equipmentCategory
72
     * @return mixed
73
     */
74
    public function update(User $user, EquipmentCategory $equipmentCategory)
0 ignored issues
show
Unused Code introduced by
The parameter $equipmentCategory 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

74
    public function update(User $user, /** @scrutinizer ignore-unused */ EquipmentCategory $equipmentCategory)

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

74
    public function update(/** @scrutinizer ignore-unused */ User $user, EquipmentCategory $equipmentCategory)

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...
75
    {
76
        return false;
77
    }
78
79
    /**
80
     * Determine whether the user can delete the model.
81
     *
82
     * @param  \App\Models\User  $user
83
     * @param  \App\Models\EquipmentCategory  $equipmentCategory
84
     * @return mixed
85
     */
86
    public function delete(User $user, EquipmentCategory $equipmentCategory)
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

86
    public function delete(/** @scrutinizer ignore-unused */ User $user, EquipmentCategory $equipmentCategory)

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 $equipmentCategory 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

86
    public function delete(User $user, /** @scrutinizer ignore-unused */ EquipmentCategory $equipmentCategory)

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...
87
    {
88
        return false;
89
    }
90
91
    /**
92
     * Determine whether the user can restore the model.
93
     *
94
     * @param  \App\Models\User  $user
95
     * @param  \App\Models\EquipmentCategory  $equipmentCategory
96
     * @return mixed
97
     */
98
    public function restore(User $user, EquipmentCategory $equipmentCategory)
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

98
    public function restore(/** @scrutinizer ignore-unused */ User $user, EquipmentCategory $equipmentCategory)

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 $equipmentCategory 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

98
    public function restore(User $user, /** @scrutinizer ignore-unused */ EquipmentCategory $equipmentCategory)

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...
99
    {
100
        return false;
101
    }
102
103
    /**
104
     * Determine whether the user can permanently delete the model.
105
     *
106
     * @param  \App\Models\User  $user
107
     * @param  \App\Models\EquipmentCategory  $equipmentCategory
108
     * @return mixed
109
     */
110
    public function forceDelete(User $user, EquipmentCategory $equipmentCategory)
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

110
    public function forceDelete(/** @scrutinizer ignore-unused */ User $user, EquipmentCategory $equipmentCategory)

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 $equipmentCategory 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

110
    public function forceDelete(User $user, /** @scrutinizer ignore-unused */ EquipmentCategory $equipmentCategory)

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...
111
    {
112
        return false;
113
    }
114
}
115