1 | <?php |
||||||
2 | |||||||
3 | namespace App\Policies; |
||||||
4 | |||||||
5 | //use Illuminate\Auth\Access\HandlesAuthorization; |
||||||
6 | |||||||
7 | use App\Federation; |
||||||
8 | use App\User; |
||||||
9 | use Illuminate\Auth\Access\HandlesAuthorization; |
||||||
10 | |||||||
11 | class FederationPolicy |
||||||
12 | { |
||||||
13 | use HandlesAuthorization; |
||||||
14 | |||||||
15 | /** |
||||||
16 | * Create a new policy instance. |
||||||
17 | * @param User $user |
||||||
18 | * @param $ability |
||||||
19 | * @return bool |
||||||
20 | */ |
||||||
21 | 1 | public function before(User $user, $ability) |
|||||
0 ignored issues
–
show
|
|||||||
22 | { |
||||||
23 | 1 | if ($user->isSuperAdmin()) { |
|||||
24 | return true; |
||||||
25 | } |
||||||
26 | 1 | return null; |
|||||
27 | } |
||||||
28 | |||||||
29 | // Only SuperAdmin should be able to create Federations |
||||||
30 | public function create(User $user) |
||||||
0 ignored issues
–
show
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. ![]() |
|||||||
31 | { |
||||||
32 | return false; |
||||||
33 | } |
||||||
34 | |||||||
35 | // Only SuperAdmin should be able to store Federations |
||||||
36 | public function store(User $user, Federation $federation) |
||||||
0 ignored issues
–
show
The parameter
$federation 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. ![]() |
|||||||
37 | { |
||||||
38 | return false; |
||||||
39 | } |
||||||
40 | |||||||
41 | // Only SuperAdmin should be able to delete Federations |
||||||
42 | public function delete(User $user, Federation $federation) |
||||||
0 ignored issues
–
show
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. ![]() The parameter
$federation 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. ![]() |
|||||||
43 | { |
||||||
44 | return false; |
||||||
45 | } |
||||||
46 | |||||||
47 | 1 | public function edit(User $user, Federation $federation) |
|||||
48 | { |
||||||
49 | 1 | if ($user->federationOwned == null) |
|||||
50 | 1 | return false; |
|||||
51 | |||||||
52 | 1 | return $user->federationOwned->id == $federation->id; |
|||||
53 | } |
||||||
54 | |||||||
55 | 1 | public function update(User $user, Federation $federation) |
|||||
56 | { |
||||||
57 | 1 | if ($user->federationOwned == null) |
|||||
58 | return false; |
||||||
59 | |||||||
60 | 1 | return $user->federationOwned->id == $federation->id; |
|||||
61 | } |
||||||
62 | |||||||
63 | |||||||
64 | } |
||||||
65 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.