Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ticket access codes deselection #1082

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 1 addition & 7 deletions app/Http/Controllers/EventTicketsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,6 @@ public function postEditTicket(Request $request, $event_id, $ticket_id)
]);
}

// Check if the ticket visibility changed on update
$ticketPreviouslyHidden = (bool)$ticket->is_hidden;

$ticket->title = $request->get('title');
$ticket->quantity_available = !$request->get('quantity_available') ? null : $request->get('quantity_available');
$ticket->price = $request->get('price');
Expand All @@ -248,16 +245,13 @@ public function postEditTicket(Request $request, $event_id, $ticket_id)
$ticket->save();

// Attach the access codes to the ticket if it's hidden and the code ids have come from the front
$ticket->event_access_codes()->detach();
if ($ticket->is_hidden) {
$ticketAccessCodes = $request->get('ticket_access_codes', []);
if (empty($ticketAccessCodes) === false) {
// Sync the access codes on the ticket
$ticket->event_access_codes()->detach();
$ticket->event_access_codes()->attach($ticketAccessCodes);
}
} else if ($ticketPreviouslyHidden) {
// Delete access codes on ticket if the visibility changed to visible
$ticket->event_access_codes()->detach();
}

return response()->json([
Expand Down