Improve contact search

This commit is contained in:
Hillel Coren 2018-02-20 21:35:45 +02:00
parent b5fc9669df
commit 45806cda7d
2 changed files with 16 additions and 1 deletions

View File

@ -131,6 +131,21 @@ class Contact extends EntityModel implements AuthenticatableContract, CanResetPa
}
}
/**
* @return mixed|string
*/
public function getSearchName()
{
$name = $this->getFullName();
$email = $this->email;
if ($name && $email) {
return sprintf('%s <%s>', $name, $email);
} else {
return $name ?: $email;
}
}
/**
* @param $contact_key
*

View File

@ -193,7 +193,7 @@ class AccountRepository
foreach ($client->contacts as $contact) {
$data['contacts'][] = [
'value' => $contact->getDisplayName(),
'value' => $contact->getSearchName(),
'tokens' => implode(',', [$contact->first_name, $contact->last_name, $contact->email, $contact->phone]),
'url' => $client->present()->url,
];