2018-03-19 09:37:35 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models\Observers;
|
|
|
|
|
|
|
|
use App\Models\Aircraft;
|
|
|
|
use App\Support\ICAO;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class AircraftObserver
|
|
|
|
*/
|
|
|
|
class AircraftObserver
|
|
|
|
{
|
2018-03-20 09:50:40 +08:00
|
|
|
/**
|
|
|
|
* @param Aircraft $aircraft
|
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
|
|
|
|
{
|
|
|
|
if (empty($aircraft->hex_code)) {
|
|
|
|
$aircraft->hex_code = ICAO::createHexCode();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|