Trim ICAO/IATA names, clean up model fields
This commit is contained in:
@@ -34,6 +34,19 @@ class Aircraft extends BaseModel
|
|||||||
'name' => 'required',
|
'name' => 'required',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callbacks
|
||||||
|
*/
|
||||||
|
protected static function boot()
|
||||||
|
{
|
||||||
|
parent::boot();
|
||||||
|
static::creating(function (Airport $model) {
|
||||||
|
if (!empty($model->icao)) {
|
||||||
|
$model->icao = strtoupper(trim($model->icao));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* foreign keys
|
* foreign keys
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -48,22 +48,17 @@ class Airport extends BaseModel
|
|||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some fancy callbacks
|
* Callbacks
|
||||||
*/
|
*/
|
||||||
protected static function boot()
|
protected static function boot()
|
||||||
{
|
{
|
||||||
|
|
||||||
parent::boot();
|
parent::boot();
|
||||||
|
|
||||||
/**
|
|
||||||
* Make sure the ID is set to the ICAO
|
|
||||||
*/
|
|
||||||
static::creating(function (Airport $model) {
|
static::creating(function (Airport $model) {
|
||||||
if(!empty($model->iata)) {
|
if(!empty($model->iata)) {
|
||||||
$model->iata = strtoupper($model->iata);
|
$model->iata = strtoupper(trim($model->iata));
|
||||||
}
|
}
|
||||||
|
|
||||||
$model->icao = strtoupper($model->icao);
|
$model->icao = strtoupper(trim($model->icao));
|
||||||
$model->id = $model->icao;
|
$model->id = $model->icao;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ class Fare extends BaseModel
|
|||||||
{
|
{
|
||||||
public $table = 'fares';
|
public $table = 'fares';
|
||||||
|
|
||||||
protected $dates = ['deleted_at'];
|
|
||||||
|
|
||||||
public $fillable = [
|
public $fillable = [
|
||||||
'code',
|
'code',
|
||||||
'name',
|
'name',
|
||||||
@@ -24,8 +22,6 @@ class Fare extends BaseModel
|
|||||||
];
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'code' => 'string',
|
|
||||||
'name' => 'string',
|
|
||||||
'price' => 'float',
|
'price' => 'float',
|
||||||
'cost' => 'float',
|
'cost' => 'float',
|
||||||
'capacity' => 'integer',
|
'capacity' => 'integer',
|
||||||
|
|||||||
@@ -11,14 +11,11 @@ class FlightFields extends BaseModel
|
|||||||
{
|
{
|
||||||
public $table = 'flight_fields';
|
public $table = 'flight_fields';
|
||||||
|
|
||||||
protected $dates = ['deleted_at'];
|
public $fillable = [
|
||||||
|
'flight_id',
|
||||||
public $fillable
|
'name',
|
||||||
= [
|
'value',
|
||||||
'flight_id',
|
];
|
||||||
'name',
|
|
||||||
'value',
|
|
||||||
];
|
|
||||||
|
|
||||||
protected $casts = [];
|
protected $casts = [];
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ class Pirep extends BaseModel
|
|||||||
];
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'id' => 'string',
|
|
||||||
'flight_time' => 'integer',
|
'flight_time' => 'integer',
|
||||||
'planned_flight_time' => 'integer',
|
'planned_flight_time' => 'integer',
|
||||||
'level' => 'integer',
|
'level' => 'integer',
|
||||||
|
|||||||
@@ -17,11 +17,6 @@ class PirepComment extends BaseModel
|
|||||||
'comment',
|
'comment',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
|
||||||
* Validation rules
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
public static $rules = [
|
public static $rules = [
|
||||||
'comment' => 'required',
|
'comment' => 'required',
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ class PirepField extends BaseModel
|
|||||||
];
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'name' => 'string',
|
|
||||||
'required' => 'boolean',
|
'required' => 'boolean',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -11,35 +11,16 @@ class PirepFieldValues extends BaseModel
|
|||||||
{
|
{
|
||||||
public $table = 'pirep_field_values';
|
public $table = 'pirep_field_values';
|
||||||
|
|
||||||
public $fillable
|
public $fillable = [
|
||||||
= [
|
'pirep_id',
|
||||||
'pirep_id',
|
'name',
|
||||||
'name',
|
'value',
|
||||||
'value',
|
'source',
|
||||||
'source',
|
];
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
public static $rules = [
|
||||||
* The attributes that should be casted to native types.
|
'name' => 'required',
|
||||||
*
|
];
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $casts
|
|
||||||
= [
|
|
||||||
'name' => 'string',
|
|
||||||
'value' => 'string',
|
|
||||||
'source' => 'string',
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validation rules
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
public static $rules
|
|
||||||
= [
|
|
||||||
'name' => 'required',
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Foreign Keys
|
* Foreign Keys
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ class Rank extends BaseModel
|
|||||||
];
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'name' => 'string',
|
|
||||||
'hours' => 'integer',
|
'hours' => 'integer',
|
||||||
'auto_approve_acars' => 'bool',
|
'auto_approve_acars' => 'bool',
|
||||||
'auto_approve_manual' => 'bool',
|
'auto_approve_manual' => 'bool',
|
||||||
@@ -29,8 +28,8 @@ class Rank extends BaseModel
|
|||||||
];
|
];
|
||||||
|
|
||||||
public static $rules = [
|
public static $rules = [
|
||||||
'name' => 'required',
|
'name' => 'required',
|
||||||
'hours' => 'required',
|
'hours' => 'required|integer',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function subfleets() {
|
public function subfleets() {
|
||||||
|
|||||||
@@ -17,18 +17,27 @@ class Setting extends BaseModel
|
|||||||
'description',
|
'description',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public static $rules = [
|
||||||
|
'name' => 'required',
|
||||||
|
'key' => 'required',
|
||||||
|
'group' => 'required',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $key
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
public static function formatKey($key)
|
public static function formatKey($key)
|
||||||
{
|
{
|
||||||
return str_replace('.', '_', strtolower($key));
|
return str_replace('.', '_', strtolower($key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callbacks
|
||||||
|
*/
|
||||||
protected static function boot()
|
protected static function boot()
|
||||||
{
|
{
|
||||||
parent::boot();
|
parent::boot();
|
||||||
|
|
||||||
/**
|
|
||||||
* Make sure any dots are replaced with underscores
|
|
||||||
*/
|
|
||||||
static::creating(function (Setting $model) {
|
static::creating(function (Setting $model) {
|
||||||
if (!empty($model->id)) {
|
if (!empty($model->id)) {
|
||||||
$model->id = Setting::formatKey($model->id);
|
$model->id = Setting::formatKey($model->id);
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ class Subfleet extends BaseModel
|
|||||||
'name',
|
'name',
|
||||||
'type',
|
'type',
|
||||||
'fuel_type',
|
'fuel_type',
|
||||||
|
'cargo_capacity',
|
||||||
|
'fuel_capacity',
|
||||||
|
'gross_weight',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user