Fix for aircraft not being detected at departure airport #781 (#789)

Aircraft not being checked/detected at departure airport #781
This commit is contained in:
Nabeel S
2020-08-17 16:44:31 -04:00
committed by GitHub
parent ac1dc49377
commit 51186bed7c
4 changed files with 124 additions and 10 deletions

View File

@@ -0,0 +1,47 @@
<?php
namespace App\Exceptions;
use App\Models\Aircraft;
class AircraftInvalid extends AbstractHttpException
{
public const MESSAGE = 'The supplied aircraft is invalid';
private $aircraft;
public function __construct(Aircraft $aircraft)
{
$this->aircraft = $aircraft;
parent::__construct(
400,
static::MESSAGE
);
}
/**
* Return the RFC 7807 error type (without the URL root)
*/
public function getErrorType(): string
{
return 'aircraft-invalid';
}
/**
* Get the detailed error string
*/
public function getErrorDetails(): string
{
return $this->getMessage();
}
/**
* Return an array with the error details, merged with the RFC7807 response
*/
public function getErrorMetadata(): array
{
return [
'aircraft_id' => optional($this->aircraft)->id,
];
}
}