feat: automatically populate past trips list

This commit is contained in:
Ben Goldsworthy 2024-11-07 15:21:04 +01:00
parent 6d716a242b
commit fb5b0347fb
Signed by: Rumperuu
SSH key fingerprint: SHA256:e5XfzNOr9UvWpEzyLfw0GtTMZWIFh3NmxH+/qQIi3xE
2 changed files with 21 additions and 4 deletions

View file

@ -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
]
);
}
/**

View file

@ -14,9 +14,10 @@
<main id="pastTripsList">
<ol>
<li><a href="/x8gkdo56o7k3eyp3w2ql">Monkey Run Scotland 2022</a></li>
<li><a href="/47xj8go928ql9mq3r20p">Europespedition III: Leds Free or Die Hard</a></li>
<li><a href="/2ozdklm6dro0951n04xg">Bentral American Diaries</a></li>
@php $DATE_FORMAT = 'M Y' @endphp
@foreach ($trips as $trip_id => $trip)
<li><a href="/{{ $trip_id }}">{{ $trip['name'] }}</a> <span>({{ $trip['start_date']->format($DATE_FORMAT) }} to {{ $trip['end_date']->format($DATE_FORMAT) }})</span></li>
@endforeach
</ol>
</main>
</body>