* Add flight level field to PIREP field closes #401

* Default value for distance 0 closes #400

* Block airline deletion if assets exist #367

* Formatting

* Move some of the base exception classes

* Fix skin references to use settings table

* Set default for theme name if setting is wrong
This commit is contained in:
Nabeel S
2019-11-19 10:06:07 -05:00
committed by GitHub
parent c643833496
commit 3ec64c989b
39 changed files with 237 additions and 117 deletions

View File

@@ -96,4 +96,14 @@ class Airline extends Model
{
$this->attributes['icao'] = strtoupper($icao);
}
public function flights()
{
return $this->belongsTo(Flight::class, 'airline_id');
}
public function pireps()
{
return $this->belongsTo(Pirep::class, 'airline_id');
}
}

View File

@@ -35,6 +35,7 @@ use Illuminate\Support\Collection;
* @property float fuel_used
* @property float distance
* @property float planned_distance
* @property int level
* @property string route
* @property int score
* @property User user
@@ -127,6 +128,7 @@ class Pirep extends Model
'arr_airport_id' => 'required',
'block_fuel' => 'required|numeric',
'fuel_used' => 'required|numeric',
'level' => 'nullable|numeric',
'notes' => 'nullable',
'route' => 'nullable',
];
@@ -296,36 +298,6 @@ class Pirep extends Model
return $field_values->sortBy('source');
}
/**
* Look up the flight, based on the PIREP flight info
*
* @param mixed $value
*
* @return Flight|null
*/
/*public function getFlightAttribute(): ?Flight
{
if (!empty($this->flight_id)) {
return Flight::find($this->flight_id);
}
$where = [
'airline_id' => $this->airline_id,
'flight_number' => $this->flight_number,
'active' => true,
];
if (filled($this->route_code)) {
$where['route_code'] = $this->route_code;
}
if (filled($this->route_leg)) {
$where['route_leg'] = $this->route_leg;
}
return Flight::where($where)->first();
}*/
/**
* Set the amount of fuel used
*

View File

@@ -18,6 +18,7 @@ use App\Models\Traits\FilesTrait;
* @property float cost_block_hour
* @property float cost_delay_minute
* @property Airline airline
* @property int airline_id
*/
class Subfleet extends Model
{