Fix some error handling
This commit is contained in:
parent
8afced3410
commit
97ee95b4da
|
@ -83,14 +83,14 @@ class Handler extends ExceptionHandler
|
||||||
$cleaned[] = snake_case($reason);
|
$cleaned[] = snake_case($reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [$field => $cleaned];
|
return [str_replace('.', '_', $field) => $cleaned];
|
||||||
})->toArray();
|
})->toArray();
|
||||||
|
|
||||||
$errors = collect($exception->errors())->map(function ($errors, $field) use ($codes) {
|
$errors = collect($exception->errors())->map(function ($errors, $field) use ($codes) {
|
||||||
$response = [];
|
$response = [];
|
||||||
foreach ($errors as $key => $error) {
|
foreach ($errors as $key => $error) {
|
||||||
$response[] = [
|
$response[] = [
|
||||||
'code' => array_get($codes, $field . '.' . $key),
|
'code' => array_get($codes, str_replace('.', '_', $field) . '.' . $key),
|
||||||
'detail' => $error,
|
'detail' => $error,
|
||||||
'source' => ['field' => $field],
|
'source' => ['field' => $field],
|
||||||
];
|
];
|
||||||
|
|
|
@ -26,11 +26,6 @@ class AllocationController extends ApplicationApiController
|
||||||
*/
|
*/
|
||||||
private $deletionService;
|
private $deletionService;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \Spatie\Fractal\Fractal
|
|
||||||
*/
|
|
||||||
private $fractal;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \Pterodactyl\Contracts\Repository\AllocationRepositoryInterface
|
* @var \Pterodactyl\Contracts\Repository\AllocationRepositoryInterface
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue