Beispiel #1
0
 public function fire()
 {
     $toDispatch = Booking::where('state', BookingState::CONFIRMED)->where('ticketsSent', 0)->get();
     $xport = \Swift_MailTransport::newInstance();
     $mailer = \Swift_Mailer::newInstance($xport);
     foreach ($toDispatch as $booking) {
         $customer = $booking->customer()->first();
         $seatSet = $booking->seatSet()->first();
         $this->info("Dispatching #{$booking->id} to {$booking->name}: {$customer->email}");
         $mail = $this->getTicketMail($this->generateTickets($booking, $seatSet, $customer), $booking, $customer);
         $mailer->send($mail);
         $booking->ticketsSent = 1;
         $booking->save();
     }
     $n = count($toDispatch);
     $this->info("Dispatched {$n} bookings.");
 }