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.
This commit is contained in:
38
app/Exceptions/AircraftNotAvailable.php
Normal file
38
app/Exceptions/AircraftNotAvailable.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?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,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user