Skip to content

Commit

Permalink
fix:remove useless code
Browse files Browse the repository at this point in the history
  • Loading branch information
rubuy-74 committed Oct 20, 2024
1 parent 090eb5b commit 664b4c0
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions app/Http/Controllers/EventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]);
}

/**
Expand Down

0 comments on commit 664b4c0

Please sign in to comment.