Check for departure airport restrictions #221
This commit is contained in:
13
app/Exceptions/AircraftNotAtAirport.php
Normal file
13
app/Exceptions/AircraftNotAtAirport.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
/**
|
||||
* Class AircraftNotAtAirport
|
||||
* @package App\Exceptions
|
||||
*/
|
||||
class AircraftNotAtAirport extends InternalError
|
||||
{
|
||||
public const FIELD = 'aircraft_id';
|
||||
public const MESSAGE = 'The aircraft is not at the departure airport';
|
||||
}
|
||||
@@ -2,24 +2,12 @@
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
/**
|
||||
* Class AircraftPermissionDenied
|
||||
* @package App\Exceptions
|
||||
*/
|
||||
class AircraftPermissionDenied extends HttpException
|
||||
class AircraftPermissionDenied extends InternalError
|
||||
{
|
||||
public function __construct(
|
||||
string $message = null,
|
||||
\Exception $previous = null,
|
||||
int $code = 0,
|
||||
array $headers = []
|
||||
) {
|
||||
parent::__construct(
|
||||
400,
|
||||
'User is not allowed to fly this aircraft',
|
||||
$previous, $headers, $code
|
||||
);
|
||||
}
|
||||
public const FIELD = 'aircraft_id';
|
||||
public const MESSAGE = 'User is not allowed to fly this aircraft';
|
||||
}
|
||||
|
||||
@@ -14,18 +14,21 @@ use Log;
|
||||
*/
|
||||
class InternalError extends ValidationException
|
||||
{
|
||||
protected const FLASH_FIELD_NAME = 'internal_error_message';
|
||||
public const FIELD = 'internal_error_message';
|
||||
public const MESSAGE = '';
|
||||
|
||||
/**
|
||||
* InternalError constructor.
|
||||
* @param string|null $message
|
||||
* @param null $field
|
||||
*/
|
||||
final public function __construct(string $message = null, $field = null)
|
||||
public function __construct(string $message = null, $field = null)
|
||||
{
|
||||
Log::error($message);
|
||||
$validator = Validator::make([], []);
|
||||
$validator->errors()->add($field ?? static::FLASH_FIELD_NAME, $message);
|
||||
$validator->errors()->add(
|
||||
$field ?? static::FIELD,
|
||||
$message ?? static::MESSAGE);
|
||||
|
||||
parent::__construct($validator);
|
||||
}
|
||||
|
||||
14
app/Exceptions/UserNotAtAirport.php
Normal file
14
app/Exceptions/UserNotAtAirport.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
|
||||
/**
|
||||
* Class UserNotAtAirport
|
||||
* @package App\Exceptions
|
||||
*/
|
||||
class UserNotAtAirport extends InternalError
|
||||
{
|
||||
public const FIELD = 'dpt_airport_id';
|
||||
public const MESSAGE = 'Pilot is not at the departure airport';
|
||||
}
|
||||
Reference in New Issue
Block a user