From 5b947fd120f4189681354f97cea612ae2ca4e29f Mon Sep 17 00:00:00 2001 From: Mh-Asmi Date: Mon, 18 Mar 2024 17:46:18 +0400 Subject: [PATCH] fix "mobile" source condition --- .../V5/Repository/Post/EloquentPostRepository.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Ushahidi/Modules/V5/Repository/Post/EloquentPostRepository.php b/src/Ushahidi/Modules/V5/Repository/Post/EloquentPostRepository.php index 3c7b0a9fa5..3b0da79794 100644 --- a/src/Ushahidi/Modules/V5/Repository/Post/EloquentPostRepository.php +++ b/src/Ushahidi/Modules/V5/Repository/Post/EloquentPostRepository.php @@ -210,14 +210,17 @@ private function setSearchCondition(PostSearchFields $search_fields, $query, boo $query->where(function ($builder) use ($search_fields) { $builder->whereNull('messages.type') ->orWhereIn('messages.type', $search_fields->source()); + if (in_array('mobile', $search_fields->source())) { + $builder->orWhere('posts.source', 'mobile'); + } }); } else { - $query->whereIn('messages.type', $search_fields->source()); - } - - // Check if $search_fields->source() contains 'mobile' and if so, add make a if else statement - if (in_array('mobile', $search_fields->source())) { - $query->orWhere('posts.source', 'mobile'); + $query->where(function ($builder) use ($search_fields) { + $builder->WhereIn('messages.type', $search_fields->source()); + if (in_array('mobile', $search_fields->source())) { + $builder->orWhere('posts.source', 'mobile'); + } + }); } }