From e577eef3244835decae9155e8822f4cc09640e78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Munsch?= Date: Wed, 12 Oct 2022 14:19:37 +0200 Subject: [PATCH] Ticket 1112: StoreTicket Labels presence check validation preventing regular user from creating tickets --- app/Http/Requests/StoreTicket.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/Http/Requests/StoreTicket.php b/app/Http/Requests/StoreTicket.php index 96b2ead..76c2966 100644 --- a/app/Http/Requests/StoreTicket.php +++ b/app/Http/Requests/StoreTicket.php @@ -97,15 +97,14 @@ class StoreTicket extends FormRequest 'file_ticket' => 'mimes:jpeg,jpg,png,pdf|max:2048', 'file_ticket2' => 'mimes:jpeg,jpg,png,pdf|max:2048', 'is_internal' => 'required|boolean', - 'labels' => [ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed - 'sometimes', 'array', function ($attribute, $value, $fail) use ($user) { + 'labels' => 'sometimes|array', + 'labels.*' => [ + 'required', 'exists:labels,id', function ($attribute, $value, $fail) use ($user) { if (!$user->can('assignLabels', Ticket::class)) { $fail(trans('Vous n\'êtes pas autorisé à modifier cette valeur')); } } - ], - 'labels.*' => 'required|exists:labels,id' + ] ]; } }