Skip to content

Commit

Permalink
🐛 show correct progressbar when manual times apply (#2278)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKrisKrisu authored Jan 19, 2024
1 parent 3d88193 commit 46ca3b1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
13 changes: 9 additions & 4 deletions app/Models/Checkin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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',
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions resources/views/includes/status.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
></div>
</div>
<div class="card-footer text-muted interaction px-3 px-md-4">
Expand Down

0 comments on commit 46ca3b1

Please sign in to comment.