Some more attribute cleanup

This commit is contained in:
Nabeel Shahzad 2018-02-06 12:01:55 -06:00
parent 56bf277fe0
commit ac0058e951

View File

@ -45,10 +45,12 @@ class Airport extends BaseModel
* Validation rules
*/
public static $rules = [
'icao' => 'required',
'name' => 'required',
'lat' => 'required',
'lon' => 'required',
'icao' => 'required',
'iata' => 'nullable',
'name' => 'required',
'location' => 'nullable',
'lat' => 'required|numeric',
'lon' => 'required|numeric',
];
/**
@ -77,6 +79,26 @@ class Airport extends BaseModel
});
}
/**
* @param $icao
*/
public function setIcaoAttribute($icao)
{
$icao = strtoupper($icao);
$this->attributes['id'] = $icao;
$this->attributes['icao'] = $icao;
}
/**
* @param $iata
*/
public function setIataAttribute($iata)
{
$iata = strtoupper($iata);
$this->attributes['iata'] = $iata;
}
/**
* Return full name like:
* KJFK - John F Kennedy