Properly set the distance/planned_distance on save (#497)
This commit is contained in:
@@ -260,16 +260,14 @@ class Pirep extends Model
|
|||||||
*/
|
*/
|
||||||
public function getProgressPercentAttribute()
|
public function getProgressPercentAttribute()
|
||||||
{
|
{
|
||||||
$upper_bound = $this->distance['nmi'];
|
$distance = $this->distance;
|
||||||
|
|
||||||
|
$upper_bound = $distance;
|
||||||
if ($this->planned_distance) {
|
if ($this->planned_distance) {
|
||||||
$upper_bound = $this->planned_distance['nmi'];
|
$upper_bound = $this->planned_distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$upper_bound) {
|
return round(($distance / $upper_bound) * 100, 0);
|
||||||
$upper_bound = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return round(($this->distance['nmi'] / $upper_bound) * 100, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user