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