orderBy('departure', 'ASC'); if (request('ids')) { $bookingIds = request('ids'); $query->whereIn('id', $bookingIds); } $bookings = $query->get()->map(function ($item, $key) { $item->departure = Carbon::parse($item->departure)->format('Y-m-d'); return $item; }); return view('exports.bookings_export', [ 'bookings' => $bookings, ]); } }