1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Policies; |
4
|
|
|
|
5
|
|
|
use App\Models\Customer; |
6
|
|
|
use App\Models\Role; |
7
|
|
|
use App\Models\User; |
8
|
|
|
use Illuminate\Auth\Access\HandlesAuthorization; |
9
|
|
|
|
10
|
|
|
class CustomerPolicy |
11
|
|
|
{ |
12
|
|
|
use HandlesAuthorization; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Perform pre-authorization checks. |
16
|
|
|
* |
17
|
|
|
* @param \App\Models\User $user |
18
|
|
|
* @param string $ability |
19
|
|
|
* @return void|bool |
20
|
|
|
*/ |
21
|
24 |
|
public function before(User $user, $ability) |
|
|
|
|
22
|
|
|
{ |
23
|
24 |
|
if ($user->hasRole([Role::ROLE_ADMIN, Role::ROLE_STAFF])) { |
24
|
24 |
|
return true; |
25
|
|
|
} |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Determine whether the user can view any models. |
30
|
|
|
* |
31
|
|
|
* @param \App\Models\User $user |
32
|
|
|
* @return \Illuminate\Auth\Access\Response|bool |
33
|
|
|
*/ |
34
|
|
|
public function viewAny(User $user) |
|
|
|
|
35
|
|
|
{ |
36
|
|
|
return false; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Determine whether the user can view the model. |
41
|
|
|
* |
42
|
|
|
* @param \App\Models\User $user |
43
|
|
|
* @param \App\Models\Customer $customer |
44
|
|
|
* @return \Illuminate\Auth\Access\Response|bool |
45
|
|
|
*/ |
46
|
|
|
public function view(User $user, Customer $customer) |
|
|
|
|
47
|
|
|
{ |
48
|
|
|
return false; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Determine whether the user can create models. |
53
|
|
|
* |
54
|
|
|
* @param \App\Models\User $user |
55
|
|
|
* @return \Illuminate\Auth\Access\Response|bool |
56
|
|
|
*/ |
57
|
|
|
public function create(User $user) |
|
|
|
|
58
|
|
|
{ |
59
|
|
|
return false; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Determine whether the user can update the model. |
64
|
|
|
* |
65
|
|
|
* @param \App\Models\User $user |
66
|
|
|
* @param \App\Models\Customer $customer |
67
|
|
|
* @return \Illuminate\Auth\Access\Response|bool |
68
|
|
|
*/ |
69
|
|
|
public function update(User $user, Customer $customer) |
|
|
|
|
70
|
|
|
{ |
71
|
|
|
return false; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Determine whether the user can delete the model. |
76
|
|
|
* |
77
|
|
|
* @param \App\Models\User $user |
78
|
|
|
* @param \App\Models\Customer $customer |
79
|
|
|
* @return \Illuminate\Auth\Access\Response|bool |
80
|
|
|
*/ |
81
|
|
|
public function delete(User $user, Customer $customer) |
|
|
|
|
82
|
|
|
{ |
83
|
|
|
return false; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Determine whether the user can restore the model. |
88
|
|
|
* |
89
|
|
|
* @param \App\Models\User $user |
90
|
|
|
* @param \App\Models\Customer $customer |
91
|
|
|
* @return \Illuminate\Auth\Access\Response|bool |
92
|
|
|
*/ |
93
|
|
|
public function restore(User $user, Customer $customer) |
|
|
|
|
94
|
|
|
{ |
95
|
|
|
return false; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* Determine whether the user can permanently delete the model. |
100
|
|
|
* |
101
|
|
|
* @param \App\Models\User $user |
102
|
|
|
* @param \App\Models\Customer $customer |
103
|
|
|
* @return \Illuminate\Auth\Access\Response|bool |
104
|
|
|
*/ |
105
|
|
|
public function forceDelete(User $user, Customer $customer) |
|
|
|
|
106
|
|
|
{ |
107
|
|
|
return false; |
108
|
|
|
} |
109
|
|
|
} |
110
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.