72 lines
1.3 KiB
PHP
72 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
/**
|
|
* Class Airport
|
|
* @package App\Models
|
|
*/
|
|
class Airport extends BaseModel
|
|
{
|
|
public $table = 'airports';
|
|
public $timestamps = false;
|
|
public $incrementing = false;
|
|
|
|
public $fillable = [
|
|
'id',
|
|
'icao',
|
|
'name',
|
|
'location',
|
|
'lat',
|
|
'lon',
|
|
'timezone',
|
|
'fuel_100ll_cost',
|
|
'fuel_jeta_cost',
|
|
'fuel_mogas_cost',
|
|
];
|
|
|
|
protected $casts = [
|
|
'lat' => 'float',
|
|
'lon' => 'float',
|
|
'fuel_100ll_cost' => 'float',
|
|
'fuel_jeta_cost' => 'float',
|
|
'fuel_mogas_cost' => 'float',
|
|
];
|
|
|
|
/**
|
|
* Validation rules
|
|
*
|
|
* @var array
|
|
*/
|
|
public static $rules = [
|
|
#'icao' => 'required|unique:airports'
|
|
];
|
|
|
|
/**
|
|
* Some fancy callbacks
|
|
*/
|
|
protected static function boot()
|
|
{
|
|
|
|
parent::boot();
|
|
|
|
/**
|
|
* Make sure the ID is set to the ICAO
|
|
*/
|
|
static::creating(function (Airport $model) {
|
|
$model->icao = strtoupper($model->icao);
|
|
$model->id = $model->icao;
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Return full name like:
|
|
* KJFK - John F Kennedy
|
|
* @return string
|
|
*/
|
|
public function getFullNameAttribute(): string
|
|
{
|
|
return $this->icao . ' - ' . $this->name;
|
|
}
|
|
}
|