2018-02-23 05:15:00 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Exceptions;
|
|
|
|
|
2019-08-21 20:17:44 +08:00
|
|
|
use App\Models\Pirep;
|
2018-02-23 05:15:00 +08:00
|
|
|
|
|
|
|
class PirepCancelled extends HttpException
|
|
|
|
{
|
2019-08-21 20:17:44 +08:00
|
|
|
private $pirep;
|
|
|
|
|
|
|
|
public function __construct(Pirep $pirep)
|
|
|
|
{
|
|
|
|
$this->pirep = $pirep;
|
2018-02-23 05:15:00 +08:00
|
|
|
parent::__construct(
|
|
|
|
400,
|
2019-08-21 20:17:44 +08:00
|
|
|
'PIREP has been cancelled, updates are not allowed'
|
2018-02-23 05:15:00 +08:00
|
|
|
);
|
|
|
|
}
|
2019-08-21 20:17:44 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the RFC 7807 error type (without the URL root)
|
|
|
|
*/
|
|
|
|
public function getErrorType(): string
|
|
|
|
{
|
|
|
|
return 'pirep-cancelled';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getErrorDetails(): string
|
|
|
|
{
|
|
|
|
return $this->getMessage();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getErrorMetadata(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'pirep_id' => $this->pirep->id,
|
|
|
|
];
|
|
|
|
}
|
2018-02-23 05:15:00 +08:00
|
|
|
}
|