From 8ef1d0187d2b6bf5018909af35ff71741f62855b Mon Sep 17 00:00:00 2001 From: Mh-Asmi Date: Tue, 19 Nov 2024 09:48:13 +0400 Subject: [PATCH] fis translations update --- .../Modules/V5/Actions/V5CommandHandler.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Ushahidi/Modules/V5/Actions/V5CommandHandler.php b/src/Ushahidi/Modules/V5/Actions/V5CommandHandler.php index 0b5eef6c16..97b02a8256 100644 --- a/src/Ushahidi/Modules/V5/Actions/V5CommandHandler.php +++ b/src/Ushahidi/Modules/V5/Actions/V5CommandHandler.php @@ -3,6 +3,7 @@ namespace Ushahidi\Modules\V5\Actions; use App\Bus\Command\AbstractCommandHandler; +use Hamcrest\Arrays\IsArray; use Ushahidi\Modules\V5\Models\Translation; use Illuminate\Http\JsonResponse; use Illuminate\Http\Exceptions\HttpResponseException; @@ -104,11 +105,17 @@ protected function updateTranslations( int $translatable_id, string $type ) { - if (empty($translation_input)) { - return []; + // if (empty($translation_input)) { + // return []; + // } + if (is_array($translation_input)) { + Translation::where('translatable_id', $translatable_id)->where('translatable_type', $type)->delete(); + if (count($translation_input)) { + return $this->saveTranslations($entity, $entity_array, $translation_input, $translatable_id, $type); + } } - Translation::where('translatable_id', $translatable_id)->where('translatable_type', $type)->delete(); - return $this->saveTranslations($entity, $entity_array, $translation_input, $translatable_id, $type); + return []; + // return $this->saveTranslations($entity, $entity_array, $translation_input, $translatable_id, $type); } //end updateTranslations() /**