Browse Source

ajustes avaliacao: max 5 files, so permite anexar foto em avaliaca negativa, nao tava exibindo foto do avaliado, pré-seleciona favorito se ja era antes

Gustavo Zanatta 1 tuần trước cách đây
mục cha
commit
087920c3c8

+ 18 - 0
app/Http/Requests/ReviewRequest.php

@@ -57,6 +57,24 @@ class ReviewRequest extends FormRequest
         return $rules;
     }
 
+    public function withValidator($validator): void
+    {
+        $validator->after(function ($validator) {
+            $photos = $this->file('photos');
+
+            if (empty($photos)) {
+                return;
+            }
+
+            if ((float) $this->input('stars') > 2) {
+                $validator->errors()->add(
+                    'photos',
+                    __('validation.custom.review.photos_only_negative'),
+                );
+            }
+        });
+    }
+
     public function messages(): array
     {
         return [

+ 1 - 0
lang/en/validation.php

@@ -232,6 +232,7 @@ return [
         'review' => [
             'already_reviewed' => 'This schedule has already been reviewed by this user.',
             'invalid_origin'   => 'The origin field must be "providers" or "clients".',
+            'photos_only_negative' => 'Photos can only be attached to reviews of up to 2 stars.',
         ],
         'review_improvement' => [
             'already_exists' => 'This improvement type is already linked to this review.',

+ 1 - 0
lang/es/validation.php

@@ -233,6 +233,7 @@ return [
         'review' => [
             'already_reviewed' => 'Esta agenda ya fue evaluada por este usuario.',
             'invalid_origin'   => 'El campo origen debe ser "providers" o "clients".',
+            'photos_only_negative' => 'Solo se pueden adjuntar fotos en evaluaciones de hasta 2 estrellas.',
         ],
         'review_improvement' => [
             'already_exists' => 'Este tipo de mejora ya está vinculado a esta evaluación.',

+ 1 - 0
lang/pt/validation.php

@@ -233,6 +233,7 @@ return [
         'review' => [
             'already_reviewed' => 'Esta agenda já foi avaliada por este usuário.',
             'invalid_origin'   => 'O campo origem deve ser "providers" ou "clients".',
+            'photos_only_negative' => 'Só é possível anexar fotos em avaliações de até 2 estrelas.',
         ],
         'review_improvement' => [
             'already_exists' => 'Este tipo de melhoria já está vinculado a esta avaliação.',