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:
parent
14cbb06bdb
commit
36ace2bb7e
@ -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 '';
|
||||
}
|
||||
|
@ -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">
|
||||
|
Loading…
Reference in New Issue
Block a user