phpvms/app/Exceptions/AircraftNotAvailable.php
B.Fatih KOZ 594d0eb222
Check Aircraft Availability (#1177)
* Check Aircraft Availability before Prefile

Check if the aircraft is available for flight (State : Parked / On Ground). If not throw new exception AircraftNotAvailable

* Add Exception

AircraftNotAvailable exception, used by PirepService during prefile checks.
2021-05-13 15:26:53 -04:00

39 lines
732 B
PHP

<?php
namespace App\Exceptions;
use App\Models\Aircraft;
class AircraftNotAvailable extends AbstractHttpException
{
public const MESSAGE = 'The aircraft is not available for flight';
private $aircraft;
public function __construct(Aircraft $aircraft)
{
$this->aircraft = $aircraft;
parent::__construct(
400,
static::MESSAGE
);
}
public function getErrorType(): string
{
return 'aircraft-not-available';
}
public function getErrorDetails(): string
{
return $this->getMessage();
}
public function getErrorMetadata(): array
{
return [
'aircraft_id' => $this->aircraft->id,
];
}
}