From 664b4c06f8aa2313a8c7cef799648e9b1b256c33 Mon Sep 17 00:00:00 2001 From: Rubem Neto Date: Sun, 20 Oct 2024 18:23:14 +0100 Subject: [PATCH] fix:remove useless code --- app/Http/Controllers/EventController.php | 32 +++++++++++------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/app/Http/Controllers/EventController.php b/app/Http/Controllers/EventController.php index db2899a..20093c3 100644 --- a/app/Http/Controllers/EventController.php +++ b/app/Http/Controllers/EventController.php @@ -103,30 +103,28 @@ public function join(Request $request, Event $event) public function remove(Request $request,Event $event, Enrollment $enrollment) { - if (Gate::allows('admin') || Gate::allows('staff', [$edition])) { - $edition = $request->input('edition'); - - $user = $enrollment->participant?->user; - - if ($edition === null) { - return response('No edition found', 500); - } + $edition = $request->input('edition'); - if ($enrollment === null) { - Log::alert('User {user} attempted to leave event "{event}" while not enrolled in the current edition', [ - 'user' => $user->name, - 'event' => $event->name, - ]); + $user = $enrollment->participant?->user; - return redirect()->route('home')->dangerBanner('Não está inscrito nesta edição!'); - } + if ($edition === null) { + return response('No edition found', 500); + } - $enrollment->events()->detach($event); - Log::info('User {user} left event "{event}"', [ + if ($enrollment === null) { + Log::alert('User {user} attempted to leave event "{event}" while not enrolled in the current edition', [ 'user' => $user->name, 'event' => $event->name, ]); + + return redirect()->route('home')->dangerBanner('Não está inscrito nesta edição!'); } + + $enrollment->events()->detach($event); + Log::info('User {user} left event "{event}"', [ + 'user' => $user->name, + 'event' => $event->name, + ]); } /**