phpvms/app/Models/Airport.php

70 lines
1.2 KiB
PHP
Raw Normal View History

<?php
namespace App\Models;
use Eloquent as Model;
/**
* Class Airport
* @package App\Models
*/
class Airport extends Model
{
public $table = 'airports';
public $timestamps = false;
public $incrementing = false;
public $fillable = [
'id',
2017-07-06 07:48:32 +08:00
'icao',
'name',
'location',
'lat',
'lon',
'timezone',
2017-07-06 07:48:32 +08:00
'fuel_100ll_cost',
'fuel_jeta_cost',
'fuel_mogas_cost',
];
protected $casts = [
];
/**
* 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;
}
}