1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Policies; |
4
|
|
|
|
5
|
|
|
use App\Models\User; |
6
|
|
|
use App\Models\UserRoles; |
7
|
|
|
use App\Traits\AllowTrait; |
8
|
|
|
use Illuminate\Auth\Access\HandlesAuthorization; |
9
|
|
|
|
10
|
|
|
class UserRolesPolicy |
11
|
|
|
{ |
12
|
|
|
use HandlesAuthorization; |
13
|
|
|
use AllowTrait; |
|
|
|
|
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Determine whether the user can view any models. |
17
|
|
|
* |
18
|
|
|
* @param \App\Models\User $user |
19
|
|
|
* @return \Illuminate\Auth\Access\Response|bool |
20
|
|
|
*/ |
21
|
|
|
public function viewAny(User $user) |
22
|
|
|
{ |
23
|
|
|
// |
24
|
|
|
return $this->checkPermission($user, 'Manage Permissions'); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Determine whether the user can view the model. |
29
|
|
|
* |
30
|
|
|
* @param \App\Models\User $user |
31
|
|
|
* @param \App\Models\UserRoles $userRoles |
32
|
|
|
* @return \Illuminate\Auth\Access\Response|bool |
33
|
|
|
*/ |
34
|
|
|
public function view(User $user, UserRoles $userRoles) |
|
|
|
|
35
|
|
|
{ |
36
|
|
|
// |
37
|
|
|
return $this->checkPermission($user, 'Manage Permissions'); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Determine whether the user can create models. |
42
|
|
|
* |
43
|
|
|
* @param \App\Models\User $user |
44
|
|
|
* @return \Illuminate\Auth\Access\Response|bool |
45
|
|
|
*/ |
46
|
|
|
public function create(User $user) |
47
|
|
|
{ |
48
|
|
|
// |
49
|
|
|
return $this->checkPermission($user, 'Manage Permissions'); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Determine whether the user can update the model. |
54
|
|
|
* |
55
|
|
|
* @param \App\Models\User $user |
56
|
|
|
* @param \App\Models\UserRoles $userRoles |
57
|
|
|
* @return \Illuminate\Auth\Access\Response|bool |
58
|
|
|
*/ |
59
|
|
|
public function update(User $user, UserRoles $userRoles) |
|
|
|
|
60
|
|
|
{ |
61
|
|
|
// |
62
|
|
|
return $this->checkPermission($user, 'Manage Permissions'); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Determine whether the user can delete the model. |
67
|
|
|
* |
68
|
|
|
* @param \App\Models\User $user |
69
|
|
|
* @param \App\Models\UserRoles $userRoles |
70
|
|
|
* @return \Illuminate\Auth\Access\Response|bool |
71
|
|
|
*/ |
72
|
|
|
public function delete(User $user, UserRoles $userRoles) |
|
|
|
|
73
|
|
|
{ |
74
|
|
|
// |
75
|
|
|
return $this->checkPermission($user, 'Manage Permissions'); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Determine whether the user can restore the model. |
80
|
|
|
* |
81
|
|
|
* @param \App\Models\User $user |
82
|
|
|
* @param \App\Models\UserRoles $userRoles |
83
|
|
|
* @return \Illuminate\Auth\Access\Response|bool |
84
|
|
|
*/ |
85
|
|
|
public function restore(User $user, UserRoles $userRoles) |
|
|
|
|
86
|
|
|
{ |
87
|
|
|
// |
88
|
|
|
return $this->checkPermission($user, 'Manage Permissions'); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Determine whether the user can permanently delete the model. |
93
|
|
|
* |
94
|
|
|
* @param \App\Models\User $user |
95
|
|
|
* @param \App\Models\UserRoles $userRoles |
96
|
|
|
* @return \Illuminate\Auth\Access\Response|bool |
97
|
|
|
*/ |
98
|
|
|
public function forceDelete(User $user, UserRoles $userRoles) |
|
|
|
|
99
|
|
|
{ |
100
|
|
|
// |
101
|
|
|
return $this->checkPermission($user, 'Manage Permissions'); |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|