phpvms/app/Exceptions/AircraftInvalid.php
Nabeel S 51186bed7c
Fix for aircraft not being detected at departure airport #781 (#789)
Aircraft not being checked/detected at departure airport #781
2020-08-17 16:44:31 -04:00

48 lines
949 B
PHP

<?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,
];
}
}