Skip to content

Commit

Permalink
fix: fix search with additional info (#5301)
Browse files Browse the repository at this point in the history
  • Loading branch information
asbiin committed Jun 23, 2021
1 parent cc385cb commit 13325cc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/Helpers/SearchHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static function searchContacts(string $needle, string $orderByColumn, str

return Contact::search($needle, $accountId, $orderByColumn, $orderByDirection)
->notes($accountId, $needle)
->introductionAdditionalInformation($needle)
->introductionAdditionalInformation($accountId, $needle)
->addressBook($accountId, $addressBookName);
}
}
11 changes: 8 additions & 3 deletions app/Models/Contact/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -592,9 +592,11 @@ public function scopeNotActive($query)
*/
public function scopeNotes($query, int $accountId = null, string $needle)
{
return $query->orWhereHas('notes', function ($query) use ($accountId, $needle) {
$maccountId = $accountId ?? Auth::user()->account_id;

return $query->orWhereHas('notes', function ($query) use ($maccountId, $needle) {
return $query->where([
['account_id', $accountId],
['account_id', $maccountId],
['body', 'like', "%$needle%"],
]);
});
Expand All @@ -606,9 +608,12 @@ public function scopeNotes($query, int $accountId = null, string $needle)
* @param Builder $query
* @return Builder
*/
public function scopeIntroductionAdditionalInformation($query, string $needle)
public function scopeIntroductionAdditionalInformation($query, int $accountId = null, string $needle)
{
$maccountId = $accountId ?? Auth::user()->account_id;

return $query->orWhere([
['account_id', $maccountId],
['first_met_additional_info', 'like', "%$needle%"],
]);
}
Expand Down

0 comments on commit 13325cc

Please sign in to comment.