CustomerPolicy   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 6
eloc 9
c 2
b 0
f 0
dl 0
loc 51
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A forceDelete() 0 3 1
A create() 0 3 1
A restore() 0 3 1
A delete() 0 3 1
A update() 0 3 1
A manage() 0 3 1
1
<?php
2
3
namespace App\Policies;
4
5
use App\Models\User;
6
use App\Traits\AllowTrait;
7
8
use Illuminate\Auth\Access\HandlesAuthorization;
9
10
class CustomerPolicy
11
{
12
    use AllowTrait;
13
    use HandlesAuthorization;
14
15
    /*
16
    * Manage customers determines if they can deactivate and recover customers
17
    */
18
    public function manage(User $user)
19
    {
20
        return $this->checkPermission($user, 'Manage Customers');
21
    }
22
23
    /**
24
     * Determine whether the user can create new customers
25
     */
26
    public function create(User $user)
27
    {
28
        return $this->checkPermission($user, 'Add Customer');
29
    }
30
31
    /**
32
     * Determine whether the user can update the customer
33
     */
34
    public function update(User $user)
35
    {
36
        return $this->checkPermission($user, 'Update Customer');
37
    }
38
39
    /**
40
     * Determine whether the user can delete the customer
41
     */
42
    public function delete(User $user)
43
    {
44
        return $this->checkPermission($user, 'Deactivate Customer');
45
    }
46
47
    /**
48
     * Determine whether the user can restore the customer
49
     */
50
    public function restore(User $user)
51
    {
52
        return $this->checkPermission($user, 'Deactivate Customer');
53
    }
54
55
    /**
56
     * Determine whether the user can permanently delete the customer
57
     */
58
    public function forceDelete(User $user)
59
    {
60
        return $this->checkPermission($user, 'Delete Customer');
61
    }
62
}
63