1 | <?php |
||||||
2 | |||||||
3 | namespace App\Policies; |
||||||
4 | |||||||
5 | use App\Association; |
||||||
6 | use App\User; |
||||||
7 | |||||||
8 | class AssociationPolicy |
||||||
9 | { |
||||||
10 | /** |
||||||
11 | * @param User $user |
||||||
12 | * @param $ability |
||||||
13 | * @return bool|null |
||||||
14 | */ |
||||||
15 | 6 | public function before(User $user, $ability) |
|||||
0 ignored issues
–
show
|
|||||||
16 | { |
||||||
17 | 6 | if ($user->isSuperAdmin()) { |
|||||
18 | 1 | return true; |
|||||
19 | } |
||||||
20 | 5 | return null; |
|||||
21 | } |
||||||
22 | |||||||
23 | // Only SuperAdmin And FederationPresident should be able to create Associations |
||||||
24 | |||||||
25 | /** |
||||||
26 | * @param User $user |
||||||
27 | * @return bool |
||||||
28 | */ |
||||||
29 | 2 | public function create(User $user) |
|||||
30 | { |
||||||
31 | 2 | if ($user->isFederationPresident()) { |
|||||
32 | 1 | return true; |
|||||
33 | } |
||||||
34 | 1 | return false; |
|||||
35 | } |
||||||
36 | |||||||
37 | // Only SuperAdmin And FederationPresident should be able to create Associations |
||||||
38 | |||||||
39 | /** |
||||||
40 | * @param User $user |
||||||
41 | * @param Association $association |
||||||
42 | * @return bool |
||||||
43 | */ |
||||||
44 | public function store(User $user, Association $association) |
||||||
0 ignored issues
–
show
The parameter
$association is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() The parameter
$user is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||||
45 | { |
||||||
46 | // if ($user->isFederationPresident()) { |
||||||
47 | return true; |
||||||
48 | // } |
||||||
49 | // return false; |
||||||
50 | } |
||||||
51 | |||||||
52 | // Only SuperAdmin And FederationPresident should be able to delete Associations |
||||||
53 | |||||||
54 | /** |
||||||
55 | * @param User $user |
||||||
56 | * @param Association $association |
||||||
57 | * @return bool |
||||||
58 | */ |
||||||
59 | public function delete(User $user, Association $association) |
||||||
60 | { |
||||||
61 | return $association->belongsToFederationPresident($user); |
||||||
62 | } |
||||||
63 | |||||||
64 | /** |
||||||
65 | * |
||||||
66 | * @param User $user |
||||||
67 | * @param Association $association |
||||||
68 | * @return bool |
||||||
69 | */ |
||||||
70 | 4 | public function edit(User $user, Association $association) |
|||||
71 | { |
||||||
72 | |||||||
73 | 4 | if ($user->isFederationPresident()) { |
|||||
74 | 1 | return $association->belongsToFederationPresident($user); |
|||||
75 | } |
||||||
76 | |||||||
77 | 3 | if ($user->isAssociationPresident()) { |
|||||
78 | 2 | return $association->belongsToAssociationPresident($user); |
|||||
79 | |||||||
80 | } |
||||||
81 | 1 | return false; |
|||||
82 | } |
||||||
83 | |||||||
84 | 1 | public function update(User $user, Association $association) |
|||||
85 | { |
||||||
86 | 1 | if ($user->isFederationPresident()) { |
|||||
87 | return $association->belongsToFederationPresident($user); |
||||||
88 | } |
||||||
89 | |||||||
90 | 1 | if ($user->isAssociationPresident()) { |
|||||
91 | 1 | return $association->belongsToAssociationPresident($user); |
|||||
92 | |||||||
93 | } |
||||||
94 | return false; |
||||||
95 | } |
||||||
96 | |||||||
97 | |||||||
98 | } |
||||||
99 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.