Reorganized PIREP page

This commit is contained in:
Nabeel Shahzad
2018-04-04 17:42:43 -05:00
parent d8dad44e43
commit 129c551fa0
3 changed files with 128 additions and 70 deletions

View File

@@ -32,6 +32,7 @@ use PhpUnitsOfMeasure\Exception\NonStringUnitName;
* @property Carbon block_on_time
* @property integer block_time
* @property integer flight_time In minutes
* @property integer planned_flight_time
* @property User user
* @property Flight|null flight
* @property Collection fields
@@ -212,6 +213,23 @@ class Pirep extends Model
}
}
/**
* Return the flight progress in a percent.
*/
public function getProgressPercentAttribute()
{
$upper_bound = $this->flight_time;
if($this->planned_flight_time) {
$upper_bound = $this->planned_flight_time;
}
if(!$upper_bound) {
$upper_bound = 1;
}
return round(($this->flight_time / $upper_bound) * 100, 0);
}
/**
* Look up the flight, based on the PIREP flight info
* @return Flight|null