public function get(Request $request, $bookingId) { $this->request = $request; if (!$this->getAuth()->hasRole('get-ticket')) { return new Response(NULL, 403); } $booking = Booking::findOrFail($bookingId); if (!$booking->ticketsGenerated) { $data = $this->generateTickets($booking); } else { $data = $this->getTicketData($bookingId); } return (new Response($data))->withHeaders(['Content-Type' => 'application/pdf']); }
public function fire() { DB::transaction(function () { $booking = Booking::findOrFail($this->argument('bookingId')); $refunds = $booking->refunds()->lists('id'); if (count($refunds)) { $nos = implode(', ', $refunds->toArray()); throw new \RuntimeException("Not re-processing; refunds already exist [{$nos}]"); } $sSet = $booking->seatSet()->first(); $sSet->annulled = TRUE; $sSet->save(); foreach ($sSet->getHeldSeats() as $seat) { DB::table('booking_seats')->where('seat_set_id', $sSet->id)->where('seat_id', $seat->seat_id)->update(['refundAmount' => $seat->pricePaid, 'void' => TRUE, 'seat_held' => FALSE]); } $refund = new Refund(); $refund->booking()->associate($booking); $refund->net = $booking->net; $refund->fees = $booking->fees; $refund->gross = $booking->gross; $refund->save(); }); }