From fb5b0347fbd1aa373d5ae527fae44f7824381f60 Mon Sep 17 00:00:00 2001 From: Rumperuu Date: Thu, 7 Nov 2024 15:21:04 +0100 Subject: [PATCH] feat: automatically populate past trips list --- app/Http/Controllers/TrackerController.php | 18 +++++++++++++++++- resources/views/past-trips.blade.php | 7 ++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/TrackerController.php b/app/Http/Controllers/TrackerController.php index cbd59fc..f584af8 100644 --- a/app/Http/Controllers/TrackerController.php +++ b/app/Http/Controllers/TrackerController.php @@ -21,7 +21,23 @@ class TrackerController extends Controller */ public function show_past_trips_list() { - return view('past-trips'); + $trips = []; + + foreach (config('app.past_trip_ids') as $tripId) { + $tripData = $this->get_trip_data($tripId, false); + $trips[$tripId] = [ + 'name' => $tripData->name, + 'start_date' => new DateTime($tripData->date_start), + 'end_date' => new DateTime($tripData->date_end) + ]; + } + + return view( + 'past-trips', + [ + 'trips' => $trips + ] + ); } /** diff --git a/resources/views/past-trips.blade.php b/resources/views/past-trips.blade.php index b246a1a..3db331f 100644 --- a/resources/views/past-trips.blade.php +++ b/resources/views/past-trips.blade.php @@ -14,9 +14,10 @@
    -
  1. Monkey Run Scotland 2022
  2. -
  3. Europespedition III: Leds Free or Die Hard
  4. -
  5. Bentral American Diaries
  6. + @php $DATE_FORMAT = 'M Y' @endphp + @foreach ($trips as $trip_id => $trip) +
  7. {{ $trip['name'] }} ({{ $trip['start_date']->format($DATE_FORMAT) }} to {{ $trip['end_date']->format($DATE_FORMAT) }})
  8. + @endforeach