Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 14 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| UpdateAdministratorRequest | |
0.00% |
0 / 14 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
| authorize | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| rules | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
2 | |||
| failedValidation | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Http\Requests; |
| 4 | |
| 5 | use App\Rules\SpanishPostalCode; |
| 6 | use Illuminate\Contracts\Validation\Validator; |
| 7 | use Illuminate\Foundation\Http\FormRequest; |
| 8 | use Illuminate\Http\Exceptions\HttpResponseException; |
| 9 | |
| 10 | class UpdateAdministratorRequest extends FormRequest |
| 11 | { |
| 12 | public function authorize(): bool |
| 13 | { |
| 14 | return true; |
| 15 | } |
| 16 | |
| 17 | public function rules(): array |
| 18 | { |
| 19 | return [ |
| 20 | 'name' => 'sometimes|required|string|max:255', |
| 21 | 'address' => 'nullable|string|max:255', |
| 22 | 'postal_code' => ['nullable', 'string', new SpanishPostalCode], |
| 23 | 'city' => 'nullable|string|max:255', |
| 24 | 'province' => 'nullable|string|max:255', |
| 25 | 'email' => 'nullable|email|max:255', |
| 26 | 'phone' => 'nullable|string|max:50', |
| 27 | 'assigned_commercial_id' => 'nullable|integer', |
| 28 | ]; |
| 29 | } |
| 30 | |
| 31 | protected function failedValidation(Validator $validator): never |
| 32 | { |
| 33 | throw new HttpResponseException( |
| 34 | response(['message' => 'KO', 'errors' => $validator->errors()], 422) |
| 35 | ); |
| 36 | } |
| 37 | } |