1
0
mirror of https://github.com/freescout-helpdesk/freescout.git synced 2024-11-24 19:33:07 +01:00

If customer without name show first part of email in profile

This commit is contained in:
FreeScout 2019-07-24 22:51:16 -07:00
parent 14cbb06bdb
commit 36ace2bb7e
2 changed files with 14 additions and 7 deletions

View File

@ -477,7 +477,7 @@ class Customer extends Model
*
* @return string
*/
public function getFullName($email_if_empty = false)
public function getFullName($email_if_empty = false, $first_part_from_email = false)
{
if ($this->first_name && $this->last_name) {
return $this->first_name.' '.$this->last_name;
@ -486,7 +486,12 @@ class Customer extends Model
} elseif (!$this->first_name && $this->last_name) {
return $this->last_name;
} elseif ($email_if_empty) {
return $this->getMainEmail();
$email = $this->getMainEmail();
if ($first_part_from_email) {
return $this->getNameFromEmail($email);
} else {
return $email;
}
}
return '';
@ -513,11 +518,13 @@ class Customer extends Model
*
* @return string
*/
public function getNameFromEmail()
public function getNameFromEmail($email = '')
{
$email = $this->emails()->first();
if (!$email) {
$email = optional($this->emails_cached()->first())->email;
}
if ($email) {
return explode('@', $email->email)[0];
return explode('@', $email)[0];
} else {
return '';
}

View File

@ -3,8 +3,8 @@
<img src="{{ $customer->getPhotoUrl() }}" alt="" class="customer-photo">
</div>
<div class="customer-data">
@if ($customer->getFullName(true))
<a href="{{ route('customers.update', ['id' => $customer->id]) }}" class="customer-name">{{ $customer->getFullName(true) }}</a>
@if ($customer->getFullName(true, true))
<a href="{{ route('customers.update', ['id' => $customer->id]) }}" class="customer-name">{{ $customer->getFullName(true, true) }}</a>
@endif
{{-- todo: display full customer info --}}
<ul class="customer-contacts customer-section">