]> git.localhorst.tv Git - alttp.git/blob - app/Policies/ApplicationPolicy.php
better chat filters
[alttp.git] / app / Policies / ApplicationPolicy.php
1 <?php
2
3 namespace App\Policies;
4
5 use App\Models\Application;
6 use App\Models\User;
7 use Illuminate\Auth\Access\HandlesAuthorization;
8
9 class ApplicationPolicy
10 {
11         use HandlesAuthorization;
12
13         /**
14          * Determine whether the user can view any models.
15          *
16          * @param  \App\Models\User  $user
17          * @return \Illuminate\Auth\Access\Response|bool
18          */
19         public function viewAny(User $user)
20         {
21                 return $user->isAdmin();
22         }
23
24         /**
25          * Determine whether the user can view the model.
26          *
27          * @param  \App\Models\User  $user
28          * @param  \App\Models\Application  $application
29          * @return \Illuminate\Auth\Access\Response|bool
30          */
31         public function view(User $user, Application $application)
32         {
33                 return $user->isAdmin()
34                         || $user->isTournamentAdmin($application->tournament)
35                         || $user->id == $application->user->id;
36         }
37
38         /**
39          * Determine whether the user can create models.
40          *
41          * @param  \App\Models\User  $user
42          * @return \Illuminate\Auth\Access\Response|bool
43          */
44         public function create(User $user)
45         {
46                 return false;
47         }
48
49         /**
50          * Determine whether the user can update the model.
51          *
52          * @param  \App\Models\User  $user
53          * @param  \App\Models\Application  $application
54          * @return \Illuminate\Auth\Access\Response|bool
55          */
56         public function update(User $user, Application $application)
57         {
58                 return false;
59         }
60
61         /**
62          * Determine whether the user can delete the model.
63          *
64          * @param  \App\Models\User  $user
65          * @param  \App\Models\Application  $application
66          * @return \Illuminate\Auth\Access\Response|bool
67          */
68         public function delete(User $user, Application $application)
69         {
70                 return false;
71         }
72
73         /**
74          * Determine whether the user can restore the model.
75          *
76          * @param  \App\Models\User  $user
77          * @param  \App\Models\Application  $application
78          * @return \Illuminate\Auth\Access\Response|bool
79          */
80         public function restore(User $user, Application $application)
81         {
82                 return false;
83         }
84
85         /**
86          * Determine whether the user can permanently delete the model.
87          *
88          * @param  \App\Models\User  $user
89          * @param  \App\Models\Application  $application
90          * @return \Illuminate\Auth\Access\Response|bool
91          */
92         public function forceDelete(User $user, Application $application)
93         {
94                 return false;
95         }
96
97         /**
98          * Determine whether the user can accept the application.
99          *
100          * @param  \App\Models\User  $user
101          * @param  \App\Models\Application  $application
102          * @return \Illuminate\Auth\Access\Response|bool
103          */
104         public function accept(User $user, Application $application)
105         {
106                 return $user->isAdmin()
107                         || $user->isTournamentAdmin($application->tournament);
108         }
109
110         /**
111          * Determine whether the user can accept the application.
112          *
113          * @param  \App\Models\User  $user
114          * @param  \App\Models\Application  $application
115          * @return \Illuminate\Auth\Access\Response|bool
116          */
117         public function reject(User $user, Application $application)
118         {
119                 return $user->isAdmin()
120                         || $user->isTournamentAdmin($application->tournament);
121         }
122
123 }