latest()->paginate(6); $tours->each(function ($tour) { $detail = $tour->tour_details->first(); $tour->nights = $detail ? Carbon::parse($detail->start_date)->diffInDays(Carbon::parse($detail->end_date)) : null; }); return view('tours.index', compact('tours')); } public function show(Tour $tour) { $tour->load([ 'tour_details', 'originAirport', 'destinationAirport', 'file', ]); $startTime = verta($tour->tour_details->first()?->start_date)->format('d-%B'); $endTime = verta($tour->tour_details->first()?->end_date)->format('d-%B'); $startTravel = verta($tour->tour_details->first()?->start_date)->format('Y-m-d'); $endTravel = verta($tour->tour_details->first()?->end_date)->format('Y-m-d'); $startDay = verta($tour->tour_details->first()?->start_date)->format('%A'); $endDay = verta($tour->tour_details->first()?->end_date)->format('%A'); return view('tours.show', compact('tour' , 'startTime' , 'endTime' , 'startTravel' , 'endTravel' , 'startDay' , 'endDay')); } }