2018-03-19 09:37:35 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models\Observers;
|
|
|
|
|
|
|
|
use App\Models\Aircraft;
|
|
|
|
use App\Support\ICAO;
|
|
|
|
|
|
|
|
class AircraftObserver
|
|
|
|
{
|
2018-03-20 09:50:40 +08:00
|
|
|
/**
|
|
|
|
* @param Aircraft $aircraft
|
2018-08-27 02:51:47 +08:00
|
|
|
*
|
2018-08-27 02:50:08 +08:00
|
|
|
* @throws \Exception
|
2018-03-20 09:50:40 +08:00
|
|
|
*/
|
2018-03-19 09:37:35 +08:00
|
|
|
public function creating(Aircraft $aircraft): void
|
|
|
|
{
|
2020-03-10 03:06:36 +08:00
|
|
|
if (!empty($aircraft->airport_id)) {
|
|
|
|
$aircraft->airport_id = strtoupper($aircraft->airport_id);
|
|
|
|
}
|
|
|
|
|
2018-03-19 09:37:35 +08:00
|
|
|
if (empty($aircraft->hex_code)) {
|
|
|
|
$aircraft->hex_code = ICAO::createHexCode();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|