|
2 | 2 |
|
3 | 3 | namespace App\Policies; |
4 | 4 |
|
5 | | -use Litepie\User\Interfaces\UserPolicyInterface; |
6 | | -use App\Repositories\Eloquent\MasterRepository; |
| 5 | +use Litepie\Master\Policies\MasterPolicy as LitepiePolicy; |
7 | 6 |
|
8 | | -class MasterPolicy |
| 7 | +class MasterPolicy extends LitepiePolicy |
9 | 8 | { |
10 | 9 |
|
11 | | - /** |
12 | | - * Determine if the given user can view the master. |
13 | | - * |
14 | | - * @param UserPolicyInterface $authUser |
15 | | - * @param MasterRepository $master |
16 | | - * |
17 | | - * @return bool |
18 | | - */ |
19 | | - public function view(UserPolicyInterface $authUser, MasterRepository $master) |
20 | | - { |
21 | | - if ($authUser->canDo('master.master.view')) { |
22 | | - return true; |
23 | | - } |
24 | | - |
25 | | - return $master->user_id == user_id() && $master->user_type == user_type(); |
26 | | - } |
27 | | - |
28 | | - /** |
29 | | - * Determine if the given user can create a master. |
30 | | - * |
31 | | - * @param UserPolicyInterface $authUser |
32 | | - * |
33 | | - * @return bool |
34 | | - */ |
35 | | - public function create(UserPolicyInterface $authUser) |
36 | | - { |
37 | | - return $authUser->canDo('master.master.create'); |
38 | | - } |
39 | | - |
40 | | - /** |
41 | | - * Determine if the given user can update the given master. |
42 | | - * |
43 | | - * @param UserPolicyInterface $authUser |
44 | | - * @param MasterRepository $master |
45 | | - * |
46 | | - * @return bool |
47 | | - */ |
48 | | - public function update(UserPolicyInterface $authUser, MasterRepository $master) |
49 | | - { |
50 | | - if ($authUser->canDo('master.master.edit')) { |
51 | | - return true; |
52 | | - } |
53 | | - |
54 | | - return $master->user_id == user_id() && $master->user_type == user_type(); |
55 | | - } |
56 | | - |
57 | | - /** |
58 | | - * Determine if the given user can delete the given master. |
59 | | - * |
60 | | - * @param UserPolicyInterface $authUser |
61 | | - * |
62 | | - * @return bool |
63 | | - */ |
64 | | - public function destroy(UserPolicyInterface $authUser, MasterRepository $master) |
65 | | - { |
66 | | - return $master->user_id == user_id() && $master->user_type == user_type(); |
67 | | - } |
68 | | - |
69 | | - /** |
70 | | - * Determine if the given user can verify the given master. |
71 | | - * |
72 | | - * @param UserPolicyInterface $authUser |
73 | | - * |
74 | | - * @return bool |
75 | | - */ |
76 | | - public function verify(UserPolicyInterface $authUser, MasterRepository $master) |
77 | | - { |
78 | | - if ($authUser->canDo('master.master.verify')) { |
79 | | - return true; |
80 | | - } |
81 | | - |
82 | | - return false; |
83 | | - } |
84 | | - |
85 | | - /** |
86 | | - * Determine if the given user can approve the given master. |
87 | | - * |
88 | | - * @param UserPolicyInterface $authUser |
89 | | - * |
90 | | - * @return bool |
91 | | - */ |
92 | | - public function approve(UserPolicyInterface $authUser, MasterRepository $master) |
93 | | - { |
94 | | - if ($authUser->canDo('master.master.approve')) { |
95 | | - return true; |
96 | | - } |
97 | | - |
98 | | - return false; |
99 | | - } |
100 | | - |
101 | | - /** |
102 | | - * Determine if the user can perform a given action ve. |
103 | | - * |
104 | | - * @param [type] $authUser [description] |
105 | | - * @param [type] $ability [description] |
106 | | - * |
107 | | - * @return [type] [description] |
108 | | - */ |
109 | | - public function before($authUser, $ability) |
110 | | - { |
111 | | - if ($authUser->isSuperuser()) { |
112 | | - return true; |
113 | | - } |
114 | | - } |
115 | 10 | } |
0 commit comments