Major refactoring and cleanup of ACARS/Pirep API

This commit is contained in:
Nabeel Shahzad
2018-01-28 11:12:13 -06:00
parent 77d0d2bcd0
commit 653ff2a104
16 changed files with 387 additions and 231 deletions

View File

@@ -37,7 +37,7 @@ class Acars extends BaseModel
'lat' => 'float',
'lon' => 'float',
'heading' => 'integer',
'altitude' => 'integer',
'altitude' => 'float',
'vs' => 'float',
'gs' => 'float',
'transponder' => 'integer',

View File

@@ -3,6 +3,7 @@
namespace App\Models;
use App\Models\Enums\AcarsType;
use App\Models\Enums\PirepState;
use App\Models\Traits\HashId;
use Illuminate\Database\Eloquent\SoftDeletes;
@@ -45,6 +46,7 @@ class Pirep extends BaseModel
];
protected $casts = [
'user_id' => 'integer',
'flight_time' => 'integer',
'planned_flight_time' => 'integer',
'level' => 'integer',
@@ -86,6 +88,20 @@ class Pirep extends BaseModel
return $flight_id;
}
/**
* Check if this PIREP is allowed to be updated
* @return bool
*/
public function allowedUpdates()
{
if ($this->state === PirepState::CANCELLED) {
return false;
}
return true;
}
/**
* Foreign Keys
*/