%PDF- %PDF-
Direktori : /www/loslex/test/app/Policies/ |
Current File : /www/loslex/test/app/Policies/RegistrationPolicy.php |
<?php namespace App\Policies; use App\Models\Registration; use App\Models\User; use Illuminate\Auth\Access\Response; class RegistrationPolicy { public function before(User $user, string $ability): bool|null { if ($user->is_admin) return true; return null; } /** * Determine whether the user can view the model. */ public function view(User $user, Registration $registration): bool { if ($user->id == $registration->user_id) return true; if ($user->is_organizer_member($registration->contest->organizer_group_id)) return true; return false; } /** * Determine whether the user can create models. */ public function create(User $user): bool { return true; } /** * Determine whether the user can update the model. */ public function update(User $user, Registration $registration): bool { if ($user->is_organizer_member($registration->contest->organizer_group_id)) return true; if ($registration->contest->isAfterReg) return false; if ($user->id == $registration->user_id) return true; return false; } /** * Determine whether the user can delete the model. */ public function delete(User $user, Registration $registration): bool { if ($user->id == $registration->user_id) return true; if ($user->is_organizer_member($registration->contest->organizer_group_id)) return true; return false; } /** * Detemine whether user can maintain registration */ public function maintain(User $user, Registration $registration): bool { if ($user->is_organizer_member($registration->contest->organizer_group_id)) return true; return false; } }