11<?php
22
3+ /*
4+ * This file is part of the API Platform project.
5+ *
6+ * (c) Kévin Dunglas <dunglas@gmail.com>
7+ *
8+ * For the full copyright and license information, please view the LICENSE
9+ * file that was distributed with this source code.
10+ */
11+
312declare (strict_types=1 );
413
514namespace Workbench \App \Http \Requests ;
@@ -23,8 +32,8 @@ protected function prepareForValidation(): void
2332 'pickupDate ' => $ this ->query ('pickupDate ' ),
2433 'pickupSlotId ' => $ this ->query ('pickupSlotId ' ),
2534 ]);
26-
2735 }
36+
2837 /**
2938 * Get the validation rules that apply to the request.
3039 *
@@ -42,14 +51,9 @@ public function rules(): array
4251 protected function failedValidation (Validator $ validator ): void
4352 {
4453 $ violations = collect ($ validator ->errors ())
45- ->map (fn ($ m , $ f ) => ['propertyPath ' => $ f , 'message ' => $ m [0 ]]) //** @phpstan-ignore-line */
54+ ->map (fn ($ m , $ f ) => ['propertyPath ' => $ f , 'message ' => $ m [0 ]]) // ** @phpstan-ignore-line */
4655 ->values ()->all ();
4756
48- throw new \ApiPlatform \Laravel \ApiResource \ValidationError (
49- $ violations [0 ]['message ' ] ?? 'Validation failed. ' ,
50- hash ('xxh3 ' , implode (', ' , array_column ($ violations , 'propertyPath ' ))),
51- new \Illuminate \Validation \ValidationException ($ validator ),
52- $ violations
53- );
57+ throw new \ApiPlatform \Laravel \ApiResource \ValidationError ($ violations [0 ]['message ' ] ?? 'Validation failed. ' , hash ('xxh3 ' , implode (', ' , array_column ($ violations , 'propertyPath ' ))), new \Illuminate \Validation \ValidationException ($ validator ), $ violations );
5458 }
5559}
0 commit comments