/** * Denormalize TicketWasCanceled event. * * @param TicketWasCanceled $event * @param TicketThatWereBookedRepository $repository * * @return TicketThatWereBooked */ public function handle(TicketWasCanceled $event, TicketThatWereBookedRepository $repository) { /** @var TicketThatWereBooked $model */ $model = $repository->findById((string) $event->id); $model->setStatus(Ticket::CANCELED); $repository->save($model); return $model; }
/** * Handle query all booked ticket. * * @param MovieBookedTicketQuery $query * @param TicketThatWereBookedRepository $repository * * @return Collection */ public function handle(MovieBookedTicketQuery $query, TicketThatWereBookedRepository $repository) { return $repository->find(array('movieId' => $query->movieId)); }
/** * Denormalize TicketWasBooked event. * * @param TicketWasBooked $event * @param TicketThatWereBookedRepository $repository * * @return TicketThatWereBooked */ public function handle(TicketWasBooked $event, TicketThatWereBookedRepository $repository) { $model = new TicketThatWereBooked($event->id->toString(), $event->movieId->toString(), $event->movieName, $event->booked->format('Y-m-d H:i:s'), $event->status); $repository->save($model); return $model; }