This commit is contained in:
Abderrahim GHAZALI 2026-07-01 05:12:32 -07:00 committed by GitHub
commit 311fb554a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 1 deletions

View file

@ -114,7 +114,7 @@ sylius_grid:
form_options:
extra_options:
class: '%sylius.model.customer.class%'
choice_label: fullname
choice_label: nameOrEmail
date:
type: date
label: sylius.ui.date

View file

@ -89,6 +89,21 @@ class Customer implements CustomerInterface, \Stringable
return trim(sprintf('%s %s', $this->firstName, $this->lastName));
}
public function getNameOrEmail(): string
{
$fullName = $this->getFullName();
if ('' !== $fullName && null !== $this->email) {
return sprintf('%s (%s)', $fullName, $this->email);
}
if ('' !== $fullName) {
return $fullName;
}
return (string) $this->email;
}
public function getFirstName(): ?string
{
return $this->firstName;

View file

@ -37,6 +37,8 @@ interface CustomerInterface extends TimestampableInterface, ResourceInterface
public function getFullName(): string;
public function getNameOrEmail(): string;
public function getFirstName(): ?string;
public function setFirstName(?string $firstName): void;