<?php
namespace App\Entity;
use App\Repository\UserRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* @ORM\Entity(repositoryClass=UserRepository::class)
* @UniqueEntity(fields={"email"}, message="There is already an account with this email")
*/
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=180, unique=true)
*/
private $email;
/**
* @ORM\Column(type="json")
*/
private $roles = [];
/**
* @var string The hashed password
* @ORM\Column(type="string")
*/
private $password;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*/
private $createdAt;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $createdBy;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $firstName;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $lastName;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $mobile2;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $landline;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $gender;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $linkedIn;
/**
* @ORM\Column(type="date", nullable=true)
*/
private $dateOfBirth;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $notes;
/**
* @ORM\ManyToMany(targetEntity=TenancyAgreements::class, mappedBy="additionTenants")
*/
private $tenancyAgreements;
/**
* @ORM\OneToMany(targetEntity=Transaction::class, mappedBy="client")
*/
private $service;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $addressStreet;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $addressCity;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $addressPostCode;
/**
* @ORM\ManyToOne(targetEntity=Countries::class)
*/
private $addressCountry;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $mobile;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $photo;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $employeeRank;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $officialFormDisplayLanguage;
public function __construct()
{
$this->tenancyAgreements = new ArrayCollection();
$this->service = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return (string)$this->email;
}
/**
* @deprecated since Symfony 5.3, use getUserIdentifier instead
*/
public function getUsername(): string
{
return (string)$this->email;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
// $roles[] = 'ROLE_CLIENT';
return array_unique($roles);
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): string
{
return $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* Returning a salt is only needed, if you are not using a modern
* hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
*
* @see UserInterface
*/
public function getSalt(): ?string
{
return null;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $date=null): self
{
$created_at = new \DateTimeImmutable('now');
if($date !=null){
$created_at = new \DateTimeImmutable($date->format('Y-m-d H:i'));
}
$this->createdAt = $created_at;
return $this;
}
public function getCreatedBy(): ?string
{
return $this->createdBy;
}
public function setCreatedBy(?string $createdBy): self
{
$this->createdBy = $createdBy;
return $this;
}
public function getFirstName(): ?string
{
return $this->firstName;
}
public function setFirstName(?string $firstName): self
{
$this->firstName = $firstName;
return $this;
}
public function getLastName(): ?string
{
return $this->lastName;
}
public function setLastName(?string $lastName): self
{
$this->lastName = $lastName;
return $this;
}
public function getFullName(): ?string
{
return $this->firstName . " " . $this->lastName;
}
public function getMobile2(): ?string
{
return $this->mobile2;
}
public function setMobile2(?string $mobile2): self
{
$this->mobile2 = $mobile2;
return $this;
}
public function getLandline(): ?string
{
return $this->landline;
}
public function setLandline(?string $landline): self
{
$this->landline = $landline;
return $this;
}
public function getGender(): ?string
{
return $this->gender;
}
public function setGender(?string $gender): self
{
$this->gender = $gender;
return $this;
}
public function getLinkedIn(): ?string
{
return $this->linkedIn;
}
public function setLinkedIn(?string $linkedIn): self
{
$this->linkedIn = $linkedIn;
return $this;
}
public function getDateOfBirth(): ?\DateTimeInterface
{
return $this->dateOfBirth;
}
public function setDateOfBirth(?\DateTimeInterface $dateOfBirth): self
{
$this->dateOfBirth = $dateOfBirth;
return $this;
}
public function getNotes(): ?string
{
return $this->notes;
}
public function setNotes(?string $notes): self
{
$this->notes = $notes;
return $this;
}
/**
* @return Collection<int, TenancyAgreements>
*/
public function getTenancyAgreements(): Collection
{
return $this->tenancyAgreements;
}
public function addTenancyAgreement(TenancyAgreements $tenancyAgreement): self
{
if (!$this->tenancyAgreements->contains($tenancyAgreement)) {
$this->tenancyAgreements[] = $tenancyAgreement;
$tenancyAgreement->addAdditionTenant($this);
}
return $this;
}
public function removeTenancyAgreement(TenancyAgreements $tenancyAgreement): self
{
if ($this->tenancyAgreements->removeElement($tenancyAgreement)) {
$tenancyAgreement->removeAdditionTenant($this);
}
return $this;
}
/**
* @return Collection<int, Transaction>
*/
public function getService(): Collection
{
return $this->service;
}
public function addService(Transaction $service): self
{
if (!$this->service->contains($service)) {
$this->service[] = $service;
$service->setClient($this);
}
return $this;
}
public function removeService(Transaction $service): self
{
if ($this->service->removeElement($service)) {
// set the owning side to null (unless already changed)
if ($service->getClient() === $this) {
$service->setClient(null);
}
}
return $this;
}
public function getAddressStreet(): ?string
{
return $this->addressStreet;
}
public function setAddressStreet(?string $addressStreet): self
{
$this->addressStreet = $addressStreet;
return $this;
}
public function getAddressCity(): ?string
{
return $this->addressCity;
}
public function setAddressCity(?string $addressCity): self
{
$this->addressCity = $addressCity;
return $this;
}
public function getAddressPostCode(): ?string
{
return $this->addressPostCode;
}
public function setAddressPostCode(?string $addressPostCode): self
{
$this->addressPostCode = $addressPostCode;
return $this;
}
public function getAddressCountry(): ?Countries
{
return $this->addressCountry;
}
public function setAddressCountry(?Countries $addressCountry): self
{
$this->addressCountry = $addressCountry;
return $this;
}
public function getMobile(): ?string
{
return $this->mobile;
}
public function setMobile(?string $mobile): self
{
$this->mobile = $mobile;
return $this;
}
public function getPhoto(): ?string
{
return $this->photo;
}
public function setPhoto(?string $photo): self
{
$this->photo = $photo;
return $this;
}
public function getEmployeeRank(): ?int
{
return $this->employeeRank;
}
public function setEmployeeRank(?int $employeeRank): self
{
$this->employeeRank = $employeeRank;
return $this;
}
public function getOfficialFormDisplayLanguage(): ?string
{
return $this->officialFormDisplayLanguage;
}
public function setOfficialFormDisplayLanguage(?string $officialFormDisplayLanguage): self
{
$this->officialFormDisplayLanguage = $officialFormDisplayLanguage;
return $this;
}
}