/** * Attach the selected packages on the bookings table * * @param $booking App\Booking * @param $content Gloudemans\Shoppingcart\CartCollection */ public function attachPackages(Booking $booking, CartCollection $items) { foreach ($items as $item) { $packageId = $item->options->selectedPackage->id; $quantity = $item->qty; $child_quantity = $item->options->child_quantity; $booking->packages()->attach($packageId, ['adult_quantity' => $quantity, 'child_quantity' => $child_quantity, 'date' => $item->options->date, 'date_submit' => $item->options->date_submit, 'time' => $item->options->time ?: '', 'ticket' => $item->options->ticket ?: '']); } }