<?php
namespace App\Entity;
use App\Model\Uploadable;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Table()
* @ORM\Entity(repositoryClass="App\Repository\CustomerRepository")
* @ORM\HasLifecycleCallbacks
*/
class Customer implements UserInterface, PasswordAuthenticatedUserInterface, \Serializable
{
use TraitEntityAddons;
/**
* Types
*/
const TYPE_INDIVIDUAL = 1;
const TYPE_SOCIETY = 2;
const TYPE_JOINT = 3;
const TYPE_CONF = [
self::TYPE_INDIVIDUAL => [
'label' => 'Particulier',
'class' => 'dark',
'icon' => 'build/icon_individual.png',
],
self::TYPE_SOCIETY => [
'label' => 'Société',
'class' => 'dark',
'icon' => 'build/icon_society.png',
],
self::TYPE_JOINT => [
'label' => 'Indivision',
'class' => 'dark',
'icon' => 'build/icon_joint.png',
],
];
/**
* Family's situation
*/
const FAMILY_SITUATION_SINGLE = 1;
const FAMILY_SITUATION_PACS = 2;
const FAMILY_SITUATION_MARRIED = 3;
const FAMILY_SITUATION_CONCUBINAGE = 4;
const FAMILY_SITUATION_WIDOWED = 5;
const FAMILY_SITUATION_DIVORCED = 6;
const FAMILY_SITUATION_CONF = [
self::FAMILY_SITUATION_SINGLE => [
'label' => 'Célibataire',
],
self::FAMILY_SITUATION_PACS => [
'label' => 'Pacs',
],
self::FAMILY_SITUATION_MARRIED => [
'label' => 'Marié',
],
self::FAMILY_SITUATION_CONCUBINAGE => [
'label' => 'Concubinage',
],
self::FAMILY_SITUATION_WIDOWED => [
'label' => 'Veuf(ve)',
],
self::FAMILY_SITUATION_DIVORCED => [
'label' => 'Divorcé(e)',
],
];
/**
* Typologies
*/
const TYPOLOGY_NONE = 0;
const TYPOLOGY_NO_ACTION_TAKEN = 1;
const TYPOLOGY_FUNDING_OBTAINED = 2;
const TYPOLOGY_NO_FINANCING = 3;
const TYPOLOGY_SEEKING_FUNDING = 4;
const TYPOLOGY_FUNDING_REFUSED = 5;
const TYPOLOGY_CONF = [
self::TYPOLOGY_NONE => [
'label' => 'Aucun projet d\'acquisition prévu',
'class' => 'light',
],
self::TYPOLOGY_NO_ACTION_TAKEN => [
'label' => 'Aucune démarche effectuée',
'class' => 'dark',
],
self::TYPOLOGY_FUNDING_OBTAINED => [
'label' => 'Financement obtenu',
'class' => 'success',
],
self::TYPOLOGY_NO_FINANCING => [
'label' => 'Achat sans financement',
'class' => 'dark',
],
self::TYPOLOGY_SEEKING_FUNDING => [
'label' => 'A la recherche d’un financement',
'class' => 'dark',
],
self::TYPOLOGY_FUNDING_REFUSED => [
'label' => 'Financement refusé',
'class' => 'danger',
],
];
/**
* Statuses
*/
const STATUS_DRAFT = 1;
const STATUS_VALIDATED = 2;
const STATUS_CONF = [
self::STATUS_DRAFT => [
'label' => 'En cours de saisie',
'class' => 'light',
],
self::STATUS_VALIDATED => [
'label' => 'Validé',
'class' => 'success',
],
];
/**
* Moods
*/
const MOOD_ANGRY = 1;
const MOOD_ANXIOUS = 2;
const MOOD_PLEASED = 3;
const MOOD_CHEERFUL = 4;
const MOOD_LOVER = 5;
const MOOD_CONF = [
self::MOOD_ANGRY => [
'label' => 'Client énervé',
'class' => 'danger',
'icon' => 'angry',
],
self::MOOD_ANXIOUS => [
'label' => 'Client inquiet',
'class' => 'warning',
'icon' => 'meh',
],
self::MOOD_PLEASED => [
'label' => 'Client content',
'class' => 'primary',
'icon' => 'smile',
],
self::MOOD_CHEERFUL => [
'label' => 'Client reconnaissant',
'class' => 'info',
'icon' => 'grin',
],
self::MOOD_LOVER => [
'label' => 'Client heureux',
'class' => 'success',
'icon' => 'grin-hearts',
],
];
/**
* Roles
*/
const ROLE_CUSTOMER = 'ROLE_CUSTOMER';
const ROLE_CONF = [
self::ROLE_CUSTOMER => [
'label' => 'Client(e)',
'class' => 'info',
],
];
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var CustomerDocument[]
*
* @ORM\OneToMany(targetEntity="CustomerDocument", mappedBy="customer", cascade={"persist", "remove"})
*/
private $documents;
/**
* @var Person[]
*
* @ORM\ManyToMany(targetEntity="Person", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\JoinTable(name="customer_persons",
* joinColumns={@ORM\JoinColumn(name="customer_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="person_id", referencedColumnName="id")}
* )
*/
private $persons;
/**
* @var Contract[]
* @ORM\OneToMany(targetEntity="Contract", mappedBy="customer", cascade={"persist", "remove"})
*/
private $contracts;
/**
* @var ContractAppointment[]
* @ORM\OneToMany(targetEntity="ContractAppointment", mappedBy="customer", cascade={"persist", "remove"})
*/
private $appointments;
/**
* @var Sponsorship[]
* @ORM\OneToMany(targetEntity="Sponsorship", mappedBy="customer", cascade={"persist", "remove"})
*/
private $sponsorships;
/**
* @var CustomerMessage[]
* @ORM\OneToMany(targetEntity="CustomerMessage", mappedBy="customer", cascade={"persist", "remove"})
*/
private $messages;
/**
* @var CustomerNotification[]
* @ORM\OneToMany(targetEntity="CustomerNotification", mappedBy="customer", cascade={"persist", "remove"})
*/
private $notifications;
/**
* @var User
*
* @ORM\ManyToOne(targetEntity="User")
* @ORM\JoinColumn(name="user_customer_service_id", referencedColumnName="id")
*/
private $userCustomerService;
/**
* @var CustomerSearch
*
* @ORM\OneToOne(targetEntity="CustomerSearch", mappedBy="customer", cascade={"persist", "remove"})
*/
private $search;
/**
* @var Address
*
* @ORM\OneToOne(targetEntity="Address", cascade={"persist", "remove"})
*/
private $address;
/**
* @var int
*
* @ORM\Column(name="netty_id", type="integer", nullable=true)
*/
private $nettyId;
/**
* @var int
*
* @ORM\Column(name="type", type="integer")
*/
private $type;
/**
* @var string
*
* @ORM\Column(name="society_name", type="string", length=100, nullable=true)
*/
private $societyName;
/**
* @var string
*
* @ORM\Column(name="society_address", type="text", nullable=true)
*/
private $societyAddress;
/**
* @var string
*
* @ORM\Column(name="society_siret", type="text", nullable=true)
*/
private $societySiret;
/**
* @var string
*
* @ORM\Column(name="remarks", type="text", nullable=true)
*/
private $remarks;
/**
* @var string
*
* @ORM\Column(name="password", type="string", length=255, nullable=true)
*/
private $password;
/**
* @var string
*
* @ORM\Column(name="email1", type="string", length=150, nullable=true)
* @Assert\Email()
*/
private $email1;
/**
* @var string
*
* @ORM\Column(name="email2", type="string", length=150, nullable=true)
* @Assert\Email()
*/
private $email2;
/**
* @var string
*
* @ORM\Column(name="phone1", type="string", length=50, nullable=true)
*/
private $phone1;
/**
* @var string
*
* @ORM\Column(name="phone2", type="string", length=50, nullable=true)
*/
private $phone2;
/**
* @var string
*
* @ORM\Column(name="phone3", type="string", length=50, nullable=true)
*/
private $phone3;
/**
* @var array
*
* @ORM\Column(name="roles", type="array")
*/
private $roles;
/**
* @var int
*
* @ORM\Column(name="family_situation", type="integer", nullable=true)
*/
private $familySituation;
/**
* @var int
*
* @ORM\Column(name="mood", type="integer", nullable=true)
*/
private $mood;
/**
* @var int
*
* @ORM\Column(name="status", type="integer")
*/
private $status;
/**
* @var string
*
* @ORM\Column(name="comment", type="text", nullable=true)
*/
private $comment;
/**
* @var string
*
* @ORM\Column(name="source", type="string", length=100, nullable=true)
*/
private $source;
/**
* @var int
*
* @ORM\Column(name="typology", type="integer")
*/
private $typology;
/**
* @var string
*
* @ORM\Column(name="forgot_password_token", type="string", length=100, nullable=true)
*/
private $forgotPasswordToken;
/**
* @var \DateTime
*
* @ORM\Column(name="forgot_password_token_expire_at", type="datetime", nullable=true)
*/
private $forgotPasswordTokenExpireAt;
/**
* @var array
*
* @ORM\Column(name="logs", type="array")
*/
private $logs;
/**
* @var \DateTime
*
* @ORM\Column(name="created_at", type="datetime")
*/
private $createdAt;
/**
* @var \DateTime
*
* @ORM\Column(name="updated_at", type="datetime")
*/
private $updatedAt;
/**
* @var \DateTime
*
* @ORM\Column(name="connected_at", type="datetime", nullable=true)
*/
private $connectedAt;
/**
* @var \DateTime
*
* @ORM\Column(name="last_call_at", type="datetime", nullable=true)
*/
private $lastCallAt;
/**
* @var \DateTime
*
* @ORM\Column(name="last_successful_call_at", type="datetime", nullable=true)
*/
private $lastSuccessfulCallAt;
/**
* @var \DateTime
*
* @ORM\Column(name="recall_at", type="datetime", nullable=true)
*/
private $recallAt;
/**
* @var \DateTime
*
* @ORM\Column(name="unreachable_at", type="datetime", nullable=true)
*/
private $unreachableAt;
/**
* @var bool
*
* @ORM\Column(name="not_duplicate", type="boolean", nullable=true)
*/
private $notDuplicate;
/**
* @var UploadedFile[]
*/
private $documentFiles;
/**
* @param User $oUser
* @param string $sMessage
* @param null $oDate
*
* @return Customer
* @throws \Exception
*/
public function addLog(User $oUser, string $sMessage, $oDate = null): Customer
{
$oDate = $oDate ?? new \DateTime();
$this->logs[] = implode(' ', ['['.$oDate->format('d/m/Y H:i').']', '['.$oUser->getHalfName().']', $sMessage]);
return $this;
}
/**
* @return bool
*/
public function isValid() : bool
{
return array_key_exists($this->type, self::TYPE_CONF) && (count($this->persons) > 0) && !empty($this->phone1)
&& !empty($this->email1) && !empty($this->address) && !empty($this->address->isValid());
}
/**
* @return bool
*/
public function isValidLight() : bool
{
return array_key_exists($this->type, self::TYPE_CONF) && (count($this->persons) > 0) && !empty($this->phone1)
&& !empty($this->email1);
}
/**
* @return bool
*/
public function hasLitigation(): bool
{
foreach ($this->contracts as $oContract) {
if ($oContract->isLitigation()) {
return true;
}
}
return false;
}
/**
* @return \DateTime
*/
public function needToBeRecallAt(): \DateTime
{
return $this->getLastCallAt() ? (clone $this->getLastCallAt())->add(new \DateInterval('P30D')) : new \DateTime();
}
/**
* @return bool
*/
public function needToBeRecallSoon(): bool
{
return empty($this->getLastCallAt()) || $this->getLastCallAt() <= (new \DateTime())->sub(new \DateInterval('P30D'));
}
/**
* @return bool
*/
public function needToBeRecallVerySoon(): bool
{
return empty($this->getLastCallAt()) || $this->getLastCallAt() <= (new \DateTime())->sub(new \DateInterval('P35D'));
}
/**
* @return string
*/
public function getExtraFullName(): string
{
$sText = $this->getId() . ' - ' . $this->getLabel() . ' - ' . $this->getEmail1();
if (!empty($this->getAddress())) {
$sText .= ' - ' . $this->getAddress();
}
$sText .= ' (' . count($this->getContracts()) . ' biens)';
return $sText;
}
/**
* @param bool $bShowOnlyPublic
*
* @return array
*/
public function toArray(bool $bShowOnlyPublic = true): array
{
$aData = $this->buildArray(['id', 'documents', 'contracts', 'appointments', 'createdAt', 'updatedAt', 'connectedAt', 'documentFiles', 'logs']);
foreach ($aData['persons'] as $iIdx => $oPerson) {
$aData['persons'][$iIdx] = $oPerson->toArray();
}
$aData['userCustomerService'] = $aData['userCustomerService'] ? $aData['userCustomerService']->toArray($bShowOnlyPublic) : $aData['userCustomerService'];
$aData['address'] = $aData['address'] ? $aData['address']->toArray(true) : $aData['address'];
$aData['search'] = $aData['search'] ? $aData['search']->toArray() : $aData['search'];
if ($bShowOnlyPublic) {
$aAllowedFields = ['phone1', 'userCustomerService'];
foreach ($aData as $sKey => $sField) {
if (!in_array($sKey, $aAllowedFields)) {
unset($aData[$sKey]);
}
}
}
return $aData;
}
/**
* @ORM\PrePersist
*/
public function prePersist()
{
$this->createdAt = $this->updatedAt = new \DateTime();
}
/**
* @ORM\PreUpdate()
*/
public function preUpdate()
{
$this->updatedAt = new \DateTime();
}
/**
* @param User $oUser
*
* @return bool
*/
public function isUserUpdateAllowed(User $oUser): bool
{
foreach ($this->getContracts() as $oContract) {
if ($oContract->getUserConsulting() === $oUser) {
return true;
}
}
return false;
}
/**
* @ORM\PreFlush()
*/
public function uploadFiles()
{
foreach ($this->documentFiles as $oFile) {
if ($oFile instanceof UploadedFile) {
$oDocument = (new CustomerDocument())
->upload($oFile, Uploadable::NAME_RANDOM, $this->getId())
->setCustomer($this)
;
$this->addDocument($oDocument);
}
}
$this->documentFiles = [];
}
/**
* @ORM\PostLoad()
*/
public function retrieveFiles()
{
$this->documentFiles = [];
foreach ($this->documents as $oDocument) {
$this->documentFiles[] = new File($oDocument->getAbsolutePath(), false);
}
}
/**
* @param UploadedFile $oFile
*
* @return $this
*/
public function addDocumentFile(UploadedFile $oFile): self
{
$this->documentFiles[] = $oFile;
return $this;
}
/**
* @return string
*/
public function getName(): string
{
return $this->getLabel();
}
/**
* @return string
*/
public function getLabel(): string
{
$aNames = [];
foreach ($this->getPersons()->toArray() as $oPerson) {
$aNames[] = mb_strtoupper($oPerson->getLastName());
}
return (!empty($this->getSocietyName()) ? $this->getSocietyName() . ' - ' : '') . implode(' - ', array_unique($aNames));
}
/**
* @return string
*/
public function getFullName(): string
{
$sText = !empty($this->getSocietyName()) ? $this->getSocietyName() . ' - ' : '';
$sText .= count($this->getPersons()) > 0 ? ucfirst($this->getFirstName()) .' '. mb_strtoupper($this->getLastName()) : '';
return $sText;
}
/**
* @return string
*/
public function getFirstName(): string
{
return count($this->getPersons()) > 0 ? $this->getPersons()[0]->getFirstName() : '';
}
/**
* @return string
*/
public function getLastName(): string
{
return count($this->getPersons()) > 0 ? $this->getPersons()[0]->getLastName() : '';
}
public function __construct()
{
$this->documentFiles = $this->logs = [];
$this->type = self::TYPE_INDIVIDUAL;
$this->status = self::STATUS_DRAFT;
$this->typology = self::TYPOLOGY_NONE;
$this->address = new Address();
$this->contracts = new ArrayCollection();
$this->appointments = new ArrayCollection();
$this->documents = new ArrayCollection();
$this->persons = new ArrayCollection();
$this->sponsorships = new ArrayCollection();
$this->messages = new ArrayCollection();
$this->notifications = new ArrayCollection();
}
/**
* @param string $sLastName
*
* @return string
*/
public function setLastName(string $sLastName): self
{
if (count($this->getPersons()) > 0) {
$this->getPersons()[0]->setLastName($sLastName);
} else {
$this->addPerson((new Person())->setFirstName('XX')->setLastName($sLastName));
}
return $this;
}
/**
* @param string $sFirstName
*
* @return string
*/
public function setFirstName(string $sFirstName): self
{
if (count($this->getPersons()) > 0) {
$this->getPersons()[0]->setFirstName($sFirstName);
} else {
$this->addPerson((new Person())->setFirstName($sFirstName)->setLastName('XX'));
}
return $this;
}
/**
* @param int $iCivility
*
* @return string
*/
public function setCivility(int $iCivility): self
{
if (count($this->getPersons()) > 0) {
$this->getPersons()[0]->setCivility($iCivility);
} else {
$this->addPerson((new Person())->setCivility($iCivility)->setFirstName('XX')->setLastName('XX'));
}
return $this;
}
/**
* @return array
*/
public function getConversations(): array
{
$aCustMessages = $this->getMessages()->toArray();
usort($aCustMessages, function (CustomerMessage $a, CustomerMessage $b) {
return ($b->getCreatedAt()->format('U') <=> $a->getCreatedAt()->format('U'));
});
$aConversations = [];
foreach ($aCustMessages as $oMessage) {
$sKey = implode('_', [$oMessage->getCategory(), $oMessage->getContract() ? $oMessage->getContract()->getRefNetty() : '']);
$aConversations[ $sKey ][] = $oMessage;
}
return $aConversations;
}
/**
* @return array
*/
public function getMobilePhones(): array
{
$aPhones = [];
foreach ([$this->phone1, $this->phone2, $this->phone3] as $sPhone) {
if (strpos($sPhone, '+336') === 0 || strpos($sPhone, '06') === 0) {
$aPhones[] = $sPhone;
}
}
return $aPhones;
}
/**
* @return string|null
*/
public function getEmail(): ?string
{
return $this->email1;
}
/**
* @return string|null
*/
public function getPhone(): ?string
{
return $this->phone1;
}
public function setEmail(string $sEmail): self
{
if (empty($sEmail)) {
$sEmail = uniqid() . '@nospam.fr';
}
$this->email1 = $sEmail;
return $this;
}
public function getId(): ?int
{
return $this->id;
}
public function getEmail1(): ?string
{
return $this->email1;
}
public function setEmail1(?string $email1): self
{
$this->email1 = $email1;
return $this;
}
/**
* @return Collection|Contract[]
*/
public function getContracts(): Collection
{
return $this->contracts;
}
public function addContract(Contract $contract): self
{
if (!$this->contracts->contains($contract)) {
$this->contracts[] = $contract;
$contract->setCustomer($this);
}
return $this;
}
public function removeContract(Contract $contract): self
{
if ($this->contracts->contains($contract)) {
$this->contracts->removeElement($contract);
// set the owning side to null (unless already changed)
if ($contract->getCustomer() === $this) {
$contract->setCustomer(null);
}
}
return $this;
}
public function getUserCustomerService(): ?User
{
return $this->userCustomerService;
}
public function setUserCustomerService(?User $userCustomerService): self
{
$this->userCustomerService = $userCustomerService;
return $this;
}
public function getStatus(): ?int
{
return $this->status;
}
public function setStatus(int $status): self
{
$this->status = $status;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* @return Collection|CustomerDocument[]
*/
public function getDocuments(): Collection
{
return $this->documents;
}
public function addDocument(CustomerDocument $document): self
{
if (!$this->documents->contains($document)) {
$this->documents[] = $document;
$document->setCustomer($this);
}
return $this;
}
public function removeDocument(CustomerDocument $document): self
{
if ($this->documents->contains($document)) {
$this->documents->removeElement($document);
// set the owning side to null (unless already changed)
if ($document->getCustomer() === $this) {
$document->setCustomer(null);
}
}
return $this;
}
public function getAddress(): ?Address
{
return $this->address;
}
public function setAddress(?Address $address): self
{
$this->address = $address;
return $this;
}
public function getPhone1(): ?string
{
return $this->phone1;
}
public function setPhone1(?string $phone1): self
{
$this->phone1 = str_replace(['+33', ' '], ['0', ''], $phone1);
return $this;
}
public function getPhone2(): ?string
{
return $this->phone2;
}
public function setPhone2(?string $phone2): self
{
$this->phone2 = str_replace(['+33', ' '], ['0', ''], $phone2);
return $this;
}
public function getPhone3(): ?string
{
return $this->phone3;
}
public function setPhone3(?string $phone3): self
{
$this->phone3 = str_replace(['+33', ' '], ['0', ''], $phone3);
return $this;
}
public function getLogs(): ?array
{
return $this->logs;
}
public function setLogs(array $logs): self
{
$this->logs = $logs;
return $this;
}
public function getType(): ?int
{
return $this->type;
}
public function setType(int $type): self
{
$this->type = $type;
return $this;
}
public function getSocietyName(): ?string
{
return $this->societyName;
}
public function setSocietyName(?string $societyName): self
{
$this->societyName = $societyName;
return $this;
}
public function getSocietyAddress(): ?string
{
return $this->societyAddress;
}
public function setSocietyAddress(?string $societyAddress): self
{
$this->societyAddress = $societyAddress;
return $this;
}
public function getRemarks(): ?string
{
return $this->remarks;
}
public function setRemarks(?string $remarks): self
{
$this->remarks = $remarks;
return $this;
}
/**
* @return Collection|Person[]
*/
public function getPersons(): Collection
{
return $this->persons;
}
public function getComment(): ?string
{
return $this->comment;
}
public function setComment(?string $comment): self
{
$this->comment = $comment;
return $this;
}
public function addPerson(Person $oPerson): self
{
if (!$this->persons->contains($oPerson)) {
$this->persons[] = $oPerson;
}
return $this;
}
public function removePerson(Person $person): self
{
if ($this->persons->contains($person)) {
$this->persons->removeElement($person);
}
return $this;
}
public function getLastCallAt(): ?\DateTimeInterface
{
return $this->lastCallAt;
}
public function setLastCallAt(?\DateTimeInterface $lastCallAt): self
{
$this->lastCallAt = $lastCallAt;
return $this;
}
public function getRecallAt(): ?\DateTimeInterface
{
return $this->recallAt;
}
public function setRecallAt(?\DateTimeInterface $recallAt): self
{
$this->recallAt = $recallAt;
return $this;
}
public function getEmail2(): ?string
{
return $this->email2;
}
public function setEmail2(?string $email2): self
{
$this->email2 = $email2;
return $this;
}
public function getNotDuplicate(): ?bool
{
return $this->notDuplicate;
}
public function setNotDuplicate(?bool $notDuplicate): self
{
$this->notDuplicate = $notDuplicate;
return $this;
}
public function getSource(): ?string
{
return $this->source;
}
public function setSource(?string $source): self
{
$this->source = $source;
return $this;
}
public function getTypology(): ?int
{
return $this->typology;
}
public function setTypology(int $typology): self
{
$this->typology = $typology;
return $this;
}
/**
* @return Collection|ContractAppointment[]
*/
public function getAppointments(): Collection
{
return $this->appointments;
}
public function addAppointment(ContractAppointment $appointment): self
{
if (!$this->appointments->contains($appointment)) {
$this->appointments[] = $appointment;
$appointment->setCustomer($this);
}
return $this;
}
public function removeAppointment(ContractAppointment $appointment): self
{
if ($this->appointments->removeElement($appointment)) {
// set the owning side to null (unless already changed)
if ($appointment->getCustomer() === $this) {
$appointment->setCustomer(null);
}
}
return $this;
}
public function getSearch(): ?CustomerSearch
{
return $this->search;
}
public function setSearch(?CustomerSearch $search): self
{
$this->search = $search;
return $this;
}
/**
* @inheritDoc
*/
public function serialize()
{
return serialize(array(
$this->id,
$this->email1,
$this->password
));
}
/**
* @inheritDoc
*/
public function unserialize($serialized)
{
[
$this->id,
$this->email1,
$this->password,
] = unserialize($serialized);
}
public function getRoles(): array
{
return $this->roles;
}
public function getPassword(): ?string
{
return $this->password;
}
public function getSalt(): ?string
{
// you *may* need a real salt depending on your encoder
// see section on salt below
return null;
}
/**
* @return string
*/
public function getUsername(): ?string
{
return $this->getUserIdentifier();
}
/**
* @return string
*/
public function getUserIdentifier(): ?string
{
return $this->email1;
}
public function eraseCredentials()
{
// TODO: Implement eraseCredentials() method.
}
public function setPassword(?string $password): self
{
$this->password = $password;
return $this;
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
public function getForgotPasswordToken(): ?string
{
return $this->forgotPasswordToken;
}
public function setForgotPasswordToken(?string $forgotPasswordToken): self
{
$this->forgotPasswordToken = $forgotPasswordToken;
return $this;
}
public function getForgotPasswordTokenExpireAt(): ?\DateTimeInterface
{
return $this->forgotPasswordTokenExpireAt;
}
public function setForgotPasswordTokenExpireAt(?\DateTimeInterface $forgotPasswordTokenExpireAt): self
{
$this->forgotPasswordTokenExpireAt = $forgotPasswordTokenExpireAt;
return $this;
}
/**
* @return Collection|Sponsorship[]
*/
public function getSponsorships(): Collection
{
return $this->sponsorships;
}
public function addSponsorship(Sponsorship $sponsorship): self
{
if (!$this->sponsorships->contains($sponsorship)) {
$this->sponsorships[] = $sponsorship;
$sponsorship->setCustomer($this);
}
return $this;
}
public function removeSponsorship(Sponsorship $sponsorship): self
{
if ($this->sponsorships->removeElement($sponsorship)) {
// set the owning side to null (unless already changed)
if ($sponsorship->getCustomer() === $this) {
$sponsorship->setCustomer(null);
}
}
return $this;
}
/**
* @return Collection|CustomerMessage[]
*/
public function getMessages(): Collection
{
return $this->messages;
}
public function addMessage(CustomerMessage $message): self
{
if (!$this->messages->contains($message)) {
$this->messages[] = $message;
$message->setCustomer($this);
}
return $this;
}
public function removeMessage(CustomerMessage $message): self
{
if ($this->messages->removeElement($message)) {
// set the owning side to null (unless already changed)
if ($message->getCustomer() === $this) {
$message->setCustomer(null);
}
}
return $this;
}
public function getUnreachableAt(): ?\DateTimeInterface
{
return $this->unreachableAt;
}
public function setUnreachableAt(?\DateTimeInterface $unreachableAt): self
{
$this->unreachableAt = $unreachableAt;
return $this;
}
public function getConnectedAt(): ?\DateTimeInterface
{
return $this->connectedAt;
}
public function setConnectedAt(?\DateTimeInterface $connectedAt): self
{
$this->connectedAt = $connectedAt;
return $this;
}
/**
* @return Collection|CustomerNotification[]
*/
public function getNotifications(): Collection
{
return $this->notifications;
}
public function addNotification(CustomerNotification $notification): self
{
if (!$this->notifications->contains($notification)) {
$this->notifications[] = $notification;
$notification->setCustomer($this);
}
return $this;
}
public function removeNotification(CustomerNotification $notification): self
{
if ($this->notifications->removeElement($notification)) {
// set the owning side to null (unless already changed)
if ($notification->getCustomer() === $this) {
$notification->setCustomer(null);
}
}
return $this;
}
public function getNettyId(): ?int
{
return $this->nettyId;
}
public function setNettyId(?int $nettyId): self
{
$this->nettyId = $nettyId;
return $this;
}
public function getSocietySiret(): ?string
{
return $this->societySiret;
}
public function setSocietySiret(?string $societySiret): self
{
$this->societySiret = $societySiret;
return $this;
}
public function getFamilySituation(): ?int
{
return $this->familySituation;
}
public function setFamilySituation(?int $familySituation): self
{
$this->familySituation = $familySituation;
return $this;
}
public function isNotDuplicate(): ?bool
{
return $this->notDuplicate;
}
public function getMood(): ?int
{
return $this->mood;
}
public function setMood(?int $mood): self
{
$this->mood = $mood;
return $this;
}
public function getLastSuccessfulCallAt(): ?\DateTimeInterface
{
return $this->lastSuccessfulCallAt;
}
public function setLastSuccessfulCallAt(?\DateTimeInterface $lastSuccessfulCallAt): self
{
$this->lastSuccessfulCallAt = $lastSuccessfulCallAt;
return $this;
}
}