src/Entity/User.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  9. use Symfony\Component\Security\Core\User\UserInterface;
  10. /**
  11.  * @ORM\Entity(repositoryClass=UserRepository::class)
  12.  * @UniqueEntity(fields={"email"}, message="There is already an account with this email")
  13.  */
  14. class User implements UserInterfacePasswordAuthenticatedUserInterface
  15. {
  16.     /**
  17.      * @ORM\Id
  18.      * @ORM\GeneratedValue
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\Column(type="string", length=180, unique=true)
  24.      */
  25.     private $email;
  26.     /**
  27.      * @ORM\Column(type="json")
  28.      */
  29.     private $roles = [];
  30.     /**
  31.      * @var string The hashed password
  32.      * @ORM\Column(type="string")
  33.      */
  34.     private $password;
  35.     /**
  36.      * @ORM\Column(type="datetime_immutable", nullable=true)
  37.      */
  38.     private $createdAt;
  39.     /**
  40.      * @ORM\Column(type="string", length=255, nullable=true)
  41.      */
  42.     private $createdBy;
  43.     /**
  44.      * @ORM\Column(type="string", length=255, nullable=true)
  45.      */
  46.     private $firstName;
  47.     /**
  48.      * @ORM\Column(type="string", length=255, nullable=true)
  49.      */
  50.     private $lastName;
  51.     /**
  52.      * @ORM\Column(type="string", length=255, nullable=true)
  53.      */
  54.     private $mobile2;
  55.     /**
  56.      * @ORM\Column(type="string", length=255, nullable=true)
  57.      */
  58.     private $landline;
  59.     /**
  60.      * @ORM\Column(type="string", length=255, nullable=true)
  61.      */
  62.     private $gender;
  63.     /**
  64.      * @ORM\Column(type="string", length=255, nullable=true)
  65.      */
  66.     private $linkedIn;
  67.     /**
  68.      * @ORM\Column(type="date", nullable=true)
  69.      */
  70.     private $dateOfBirth;
  71.     /**
  72.      * @ORM\Column(type="text", nullable=true)
  73.      */
  74.     private $notes;
  75.     /**
  76.      * @ORM\ManyToMany(targetEntity=TenancyAgreements::class, mappedBy="additionTenants")
  77.      */
  78.     private $tenancyAgreements;
  79.     /**
  80.      * @ORM\OneToMany(targetEntity=Transaction::class, mappedBy="client")
  81.      */
  82.     private $service;
  83.     /**
  84.      * @ORM\Column(type="string", length=255, nullable=true)
  85.      */
  86.     private $addressStreet;
  87.     /**
  88.      * @ORM\Column(type="string", length=255, nullable=true)
  89.      */
  90.     private $addressCity;
  91.     /**
  92.      * @ORM\Column(type="string", length=255, nullable=true)
  93.      */
  94.     private $addressPostCode;
  95.     /**
  96.      * @ORM\ManyToOne(targetEntity=Countries::class)
  97.      */
  98.     private $addressCountry;
  99.     /**
  100.      * @ORM\Column(type="string", length=255, nullable=true)
  101.      */
  102.     private $mobile;
  103.     /**
  104.      * @ORM\Column(type="string", length=255, nullable=true)
  105.      */
  106.     private $photo;
  107.     /**
  108.      * @ORM\Column(type="integer", nullable=true)
  109.      */
  110.     private $employeeRank;
  111.     /**
  112.      * @ORM\Column(type="string", length=255, nullable=true)
  113.      */
  114.     private $officialFormDisplayLanguage;
  115.     public function __construct()
  116.     {
  117.         $this->tenancyAgreements = new ArrayCollection();
  118.         $this->service = new ArrayCollection();
  119.     }
  120.     public function getId(): ?int
  121.     {
  122.         return $this->id;
  123.     }
  124.     public function getEmail(): ?string
  125.     {
  126.         return $this->email;
  127.     }
  128.     public function setEmail(string $email): self
  129.     {
  130.         $this->email $email;
  131.         return $this;
  132.     }
  133.     /**
  134.      * A visual identifier that represents this user.
  135.      *
  136.      * @see UserInterface
  137.      */
  138.     public function getUserIdentifier(): string
  139.     {
  140.         return (string)$this->email;
  141.     }
  142.     /**
  143.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  144.      */
  145.     public function getUsername(): string
  146.     {
  147.         return (string)$this->email;
  148.     }
  149.     /**
  150.      * @see UserInterface
  151.      */
  152.     public function getRoles(): array
  153.     {
  154.         $roles $this->roles;
  155. //                $roles[] = 'ROLE_CLIENT';
  156.         return array_unique($roles);
  157.     }
  158.     public function setRoles(array $roles): self
  159.     {
  160.         $this->roles $roles;
  161.         return $this;
  162.     }
  163.     /**
  164.      * @see PasswordAuthenticatedUserInterface
  165.      */
  166.     public function getPassword(): string
  167.     {
  168.         return $this->password;
  169.     }
  170.     public function setPassword(string $password): self
  171.     {
  172.         $this->password $password;
  173.         return $this;
  174.     }
  175.     /**
  176.      * Returning a salt is only needed, if you are not using a modern
  177.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  178.      *
  179.      * @see UserInterface
  180.      */
  181.     public function getSalt(): ?string
  182.     {
  183.         return null;
  184.     }
  185.     /**
  186.      * @see UserInterface
  187.      */
  188.     public function eraseCredentials()
  189.     {
  190.         // If you store any temporary, sensitive data on the user, clear it here
  191.         // $this->plainPassword = null;
  192.     }
  193.     public function getCreatedAt(): ?\DateTimeImmutable
  194.     {
  195.         return $this->createdAt;
  196.     }
  197.     public function setCreatedAt(\DateTimeInterface $date=null): self
  198.     {
  199.         $created_at = new \DateTimeImmutable('now');
  200.         if($date !=null){
  201.             $created_at = new \DateTimeImmutable($date->format('Y-m-d H:i'));
  202.         }
  203.         $this->createdAt $created_at;
  204.         return $this;
  205.     }
  206.     public function getCreatedBy(): ?string
  207.     {
  208.         return $this->createdBy;
  209.     }
  210.     public function setCreatedBy(?string $createdBy): self
  211.     {
  212.         $this->createdBy $createdBy;
  213.         return $this;
  214.     }
  215.     public function getFirstName(): ?string
  216.     {
  217.         return $this->firstName;
  218.     }
  219.     public function setFirstName(?string $firstName): self
  220.     {
  221.         $this->firstName $firstName;
  222.         return $this;
  223.     }
  224.     public function getLastName(): ?string
  225.     {
  226.         return $this->lastName;
  227.     }
  228.     public function setLastName(?string $lastName): self
  229.     {
  230.         $this->lastName $lastName;
  231.         return $this;
  232.     }
  233.     public function getFullName(): ?string
  234.     {
  235.         return $this->firstName " " $this->lastName;
  236.     }
  237.     public function getMobile2(): ?string
  238.     {
  239.         return $this->mobile2;
  240.     }
  241.     public function setMobile2(?string $mobile2): self
  242.     {
  243.         $this->mobile2 $mobile2;
  244.         return $this;
  245.     }
  246.     public function getLandline(): ?string
  247.     {
  248.         return $this->landline;
  249.     }
  250.     public function setLandline(?string $landline): self
  251.     {
  252.         $this->landline $landline;
  253.         return $this;
  254.     }
  255.     public function getGender(): ?string
  256.     {
  257.         return $this->gender;
  258.     }
  259.     public function setGender(?string $gender): self
  260.     {
  261.         $this->gender $gender;
  262.         return $this;
  263.     }
  264.     public function getLinkedIn(): ?string
  265.     {
  266.         return $this->linkedIn;
  267.     }
  268.     public function setLinkedIn(?string $linkedIn): self
  269.     {
  270.         $this->linkedIn $linkedIn;
  271.         return $this;
  272.     }
  273.     public function getDateOfBirth(): ?\DateTimeInterface
  274.     {
  275.         return $this->dateOfBirth;
  276.     }
  277.     public function setDateOfBirth(?\DateTimeInterface $dateOfBirth): self
  278.     {
  279.         $this->dateOfBirth $dateOfBirth;
  280.         return $this;
  281.     }
  282.     public function getNotes(): ?string
  283.     {
  284.         return $this->notes;
  285.     }
  286.     public function setNotes(?string $notes): self
  287.     {
  288.         $this->notes $notes;
  289.         return $this;
  290.     }
  291.     /**
  292.      * @return Collection<int, TenancyAgreements>
  293.      */
  294.     public function getTenancyAgreements(): Collection
  295.     {
  296.         return $this->tenancyAgreements;
  297.     }
  298.     public function addTenancyAgreement(TenancyAgreements $tenancyAgreement): self
  299.     {
  300.         if (!$this->tenancyAgreements->contains($tenancyAgreement)) {
  301.             $this->tenancyAgreements[] = $tenancyAgreement;
  302.             $tenancyAgreement->addAdditionTenant($this);
  303.         }
  304.         return $this;
  305.     }
  306.     public function removeTenancyAgreement(TenancyAgreements $tenancyAgreement): self
  307.     {
  308.         if ($this->tenancyAgreements->removeElement($tenancyAgreement)) {
  309.             $tenancyAgreement->removeAdditionTenant($this);
  310.         }
  311.         return $this;
  312.     }
  313.     /**
  314.      * @return Collection<int, Transaction>
  315.      */
  316.     public function getService(): Collection
  317.     {
  318.         return $this->service;
  319.     }
  320.     public function addService(Transaction $service): self
  321.     {
  322.         if (!$this->service->contains($service)) {
  323.             $this->service[] = $service;
  324.             $service->setClient($this);
  325.         }
  326.         return $this;
  327.     }
  328.     public function removeService(Transaction $service): self
  329.     {
  330.         if ($this->service->removeElement($service)) {
  331.             // set the owning side to null (unless already changed)
  332.             if ($service->getClient() === $this) {
  333.                 $service->setClient(null);
  334.             }
  335.         }
  336.         return $this;
  337.     }
  338.     public function getAddressStreet(): ?string
  339.     {
  340.         return $this->addressStreet;
  341.     }
  342.     public function setAddressStreet(?string $addressStreet): self
  343.     {
  344.         $this->addressStreet $addressStreet;
  345.         return $this;
  346.     }
  347.     public function getAddressCity(): ?string
  348.     {
  349.         return $this->addressCity;
  350.     }
  351.     public function setAddressCity(?string $addressCity): self
  352.     {
  353.         $this->addressCity $addressCity;
  354.         return $this;
  355.     }
  356.     public function getAddressPostCode(): ?string
  357.     {
  358.         return $this->addressPostCode;
  359.     }
  360.     public function setAddressPostCode(?string $addressPostCode): self
  361.     {
  362.         $this->addressPostCode $addressPostCode;
  363.         return $this;
  364.     }
  365.     public function getAddressCountry(): ?Countries
  366.     {
  367.         return $this->addressCountry;
  368.     }
  369.     public function setAddressCountry(?Countries $addressCountry): self
  370.     {
  371.         $this->addressCountry $addressCountry;
  372.         return $this;
  373.     }
  374.     public function getMobile(): ?string
  375.     {
  376.         return $this->mobile;
  377.     }
  378.     public function setMobile(?string $mobile): self
  379.     {
  380.         $this->mobile $mobile;
  381.         return $this;
  382.     }
  383.     public function getPhoto(): ?string
  384.     {
  385.         return $this->photo;
  386.     }
  387.     public function setPhoto(?string $photo): self
  388.     {
  389.         $this->photo $photo;
  390.         return $this;
  391.     }
  392.     public function getEmployeeRank(): ?int
  393.     {
  394.         return $this->employeeRank;
  395.     }
  396.     public function setEmployeeRank(?int $employeeRank): self
  397.     {
  398.         $this->employeeRank $employeeRank;
  399.         return $this;
  400.     }
  401.     public function getOfficialFormDisplayLanguage(): ?string
  402.     {
  403.         return $this->officialFormDisplayLanguage;
  404.     }
  405.     public function setOfficialFormDisplayLanguage(?string $officialFormDisplayLanguage): self
  406.     {
  407.         $this->officialFormDisplayLanguage $officialFormDisplayLanguage;
  408.         return $this;
  409.     }
  410. }