From 46ca3b13c012a80835c7c4c5e1c4cdb6e039668f Mon Sep 17 00:00:00 2001 From: Kris Date: Fri, 19 Jan 2024 19:24:31 +0100 Subject: [PATCH] :bug: show correct progressbar when manual times apply (#2278) --- app/Models/Checkin.php | 13 +++++++++---- resources/views/includes/status.blade.php | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/Models/Checkin.php b/app/Models/Checkin.php index a9e293f49..4bc3adeaa 100644 --- a/app/Models/Checkin.php +++ b/app/Models/Checkin.php @@ -11,8 +11,8 @@ use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Auth; -use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Gate; +use stdClass; /** * //properties @@ -42,6 +42,11 @@ * @property Station $destinationStation * @property Stopover $destinationStopover * + * //appends + * @property float $speed + * @property stdClass $displayDeparture + * @property stdClass $displayArrival + * * @todo rename table to "Checkin" (without Train - we have more than just trains) * @todo merge model with "Status" because the difference between trip sources (HAFAS, * User, and future sources) should be handled in the Trip model. @@ -59,7 +64,7 @@ class Checkin extends Model 'distance', 'duration', 'departure', 'manual_departure', 'arrival', 'manual_arrival', 'points', 'forced', ]; protected $hidden = ['created_at', 'updated_at']; - protected $appends = ['speed']; + protected $appends = ['speed', 'displayDeparture', 'displayArrival']; protected $casts = [ 'id' => 'integer', 'status_id' => 'integer', @@ -137,7 +142,7 @@ private static function prepareDisplayTime($planned, $real = null, $manual = nul ]; } - public function getDisplayDepartureAttribute(): \stdClass { + public function getDisplayDepartureAttribute(): stdClass { $planned = $this->originStopover?->departure_planned ?? $this->originStopover?->departure ?? $this->departure; @@ -146,7 +151,7 @@ public function getDisplayDepartureAttribute(): \stdClass { return (object) self::prepareDisplayTime($planned, $real, $manual); } - public function getDisplayArrivalAttribute(): \stdClass { + public function getDisplayArrivalAttribute(): stdClass { $planned = $this->destinationStopover?->arrival_planned ?? $this->destinationStopover?->arrival ?? $this->arrival; diff --git a/resources/views/includes/status.blade.php b/resources/views/includes/status.blade.php index 4094bbd87..28ceaa0a8 100644 --- a/resources/views/includes/status.blade.php +++ b/resources/views/includes/status.blade.php @@ -158,8 +158,8 @@ class="progress-bar progress-time {{ $status->event?->isPride ? 'progress-pride' role="progressbar" style="width: 0" data-valuenow="{{ time() }}" - data-valuemin="{{ $status->checkin?->originStopover?->departure->timestamp ?? $status->checkin->departure->timestamp }}" - data-valuemax="{{ $status->checkin?->destinationStopover?->arrival->timestamp ?? $status->checkin->arrival->timestamp }}" + data-valuemin="{{ $status->checkin->displayDeparture->time->timestamp }}" + data-valuemax="{{ $status->checkin->displayArrival->time->timestamp }}" >