From aafc9680bfc555fc546b78552ac9bdde980d4d1d Mon Sep 17 00:00:00 2001 From: Nabeel S Date: Tue, 14 Jan 2020 13:45:22 -0500 Subject: [PATCH] Properly set the distance/planned_distance on save (#497) --- app/Models/Pirep.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/Models/Pirep.php b/app/Models/Pirep.php index d032ec28..d8c338a5 100644 --- a/app/Models/Pirep.php +++ b/app/Models/Pirep.php @@ -260,16 +260,14 @@ class Pirep extends Model */ public function getProgressPercentAttribute() { - $upper_bound = $this->distance['nmi']; + $distance = $this->distance; + + $upper_bound = $distance; if ($this->planned_distance) { - $upper_bound = $this->planned_distance['nmi']; + $upper_bound = $this->planned_distance; } - if (!$upper_bound) { - $upper_bound = 1; - } - - return round(($this->distance['nmi'] / $upper_bound) * 100, 0); + return round(($distance / $upper_bound) * 100, 0); } /**