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