src/Entity/Resident.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use DateTime;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  8. use Symfony\Component\Security\Core\User\UserInterface;
  9. use Symfony\Component\Serializer\Annotation\Ignore;
  10. /**
  11.  * @ORM\Entity(repositoryClass="App\Repository\ResidentRepository")
  12.  * @ORM\Table(name="residents")
  13.  * * @ORM\HasLifecycleCallbacks()
  14.  */
  15. class Resident implements UserInterfacePasswordAuthenticatedUserInterface
  16. {
  17.     /**
  18.      * @ORM\Id
  19.      * @ORM\GeneratedValue
  20.      * @ORM\Column(type="integer")
  21.      */
  22.     private int $id;
  23.     /**
  24.      * @ORM\Column(type="string", length=180, unique=true)
  25.      */
  26.     private string $email;
  27.     /**
  28.      * @ORM\Column(type="string", length=255, nullable=true)
  29.      */
  30.     private string|null $firstname;
  31.     /**
  32.      * @ORM\Column(type="string", length=255, nullable=true)
  33.      */
  34.     private string|null $lastname;
  35.     /**
  36.      * @var array<string>
  37.      * @ORM\Column(type="json")
  38.      */
  39.     private array $roles = [];
  40.     /**
  41.      * @var string The hashed password
  42.      * @ORM\Column(type="string")
  43.      */
  44.     #[Ignore]
  45.     private string $password;
  46.     /**
  47.      * @var Collection<int, Flat>
  48.      * @ORM\OneToMany(targetEntity="App\Entity\Flat", mappedBy="resident")
  49.      */
  50.     private Collection $flats;
  51.     /**
  52.      * @ORM\Column(type="string", length=12, nullable=true)
  53.      */
  54.     private string|null $resetPasswordCode null;
  55.     /**
  56.      * @ORM\Column(type="boolean")
  57.      */
  58.     private bool $hasAcceptedTerms;
  59.     /**
  60.      * @ORM\Column(name="created_at", type="datetime")
  61.      */
  62.     private DateTime|null $createdAt;
  63.     /**
  64.      * @ORM\Column(name="updated_at", type="datetime", nullable=true)
  65.      */
  66.     private DateTime|null $updatedAt;
  67.     /**
  68.      * @ORM\Column(type="boolean")
  69.      */
  70.     private bool $disabled false;
  71.     public function __construct()
  72.     {
  73.         $this->flats = new ArrayCollection();
  74.     }
  75.     public function getId(): ?int
  76.     {
  77.         return $this->id;
  78.     }
  79.     public function getEmail(): ?string
  80.     {
  81.         return $this->email;
  82.     }
  83.     public function setEmail(string $email): Resident
  84.     {
  85.         $this->email $email;
  86.         return $this;
  87.     }
  88.     /**
  89.      * A visual identifier that represents this user.
  90.      *
  91.      * @see UserInterface
  92.      */
  93.     public function getUsername(): string
  94.     {
  95.         return (string) $this->email;
  96.     }
  97.     public function getRoles(): array
  98.     {
  99.         return $this->roles;
  100.     }
  101.     /**
  102.      * @param array<string> $roles
  103.      * @return $this
  104.      */
  105.     public function setRoles(array $roles): Resident
  106.     {
  107.         $this->roles $roles;
  108.         return $this;
  109.     }
  110.     /**
  111.      * @see UserInterface
  112.      */
  113.     #[Ignore]
  114.     public function getPassword(): string
  115.     {
  116.         return (string) $this->password;
  117.     }
  118.     /**
  119.      * @param string $password
  120.      * @return Resident
  121.      */
  122.     #[Ignore]
  123.     public function setPassword(string $password): Resident
  124.     {
  125.         $this->password $password;
  126.         return $this;
  127.     }
  128.     /**
  129.      * @return Collection<int, Flat>
  130.      */
  131.     public function getFlats(): Collection
  132.     {
  133.         return $this->flats;
  134.     }
  135.     public function addFlat(Flat $flat): Resident
  136.     {
  137.         if (!$this->flats->contains($flat)) {
  138.             $this->flats[] = $flat;
  139.             $flat->setResident($this);
  140.         }
  141.         return $this;
  142.     }
  143.     /**
  144.      * @param Collection<int, Flat> $flats
  145.      * @return $this
  146.      */
  147.     public function setFlats(Collection $flats): Resident
  148.     {
  149.         foreach ($flats as $flat) {
  150.             if (!$this->flats->contains($flat)) {
  151.                 $this->flats[] = $flat;
  152.                 $flat->setResident($this);
  153.             }
  154.         }
  155.         return $this;
  156.     }
  157.     public function removeFlat(Flat $flat): Resident
  158.     {
  159.         if ($this->flats->removeElement($flat)) {
  160.             // set the owning side to null (unless already changed)
  161.             if ($flat->getResident() === $this) {
  162.                 $flat->setResident(null);
  163.             }
  164.         }
  165.         return $this;
  166.     }
  167.     public function getHasAcceptedTerms(): ?bool
  168.     {
  169.         return $this->hasAcceptedTerms;
  170.     }
  171.     public function setHasAcceptedTerms(bool $hasAcceptedTerms): Resident
  172.     {
  173.         $this->hasAcceptedTerms $hasAcceptedTerms;
  174.         return $this;
  175.     }
  176.     public function getFirstname(): ?string
  177.     {
  178.         return $this->firstname;
  179.     }
  180.     public function setFirstname(?string $firstname): Resident
  181.     {
  182.         $this->firstname $firstname;
  183.         return $this;
  184.     }
  185.     public function getLastname(): ?string
  186.     {
  187.         return $this->lastname;
  188.     }
  189.     public function setLastname(?string $lastname): Resident
  190.     {
  191.         $this->lastname $lastname;
  192.         return $this;
  193.     }
  194.     public function getUserIdentifier(): string
  195.     {
  196.         return $this->getEmail();
  197.     }
  198.     public function eraseCredentials(): void
  199.     {
  200.         // TODO: Implement eraseCredentials() method.
  201.     }
  202.     /**
  203.      * @return string|null
  204.      */
  205.     public function getResetPasswordCode(): ?string
  206.     {
  207.         return $this->resetPasswordCode;
  208.     }
  209.     /**
  210.      * @param string|null $resetPasswordCode
  211.      */
  212.     public function setResetPasswordCode(?string $resetPasswordCode): void
  213.     {
  214.         $this->resetPasswordCode $resetPasswordCode;
  215.     }
  216.     /**
  217.      * @return DateTime|null
  218.      */
  219.     public function getCreatedAt(): ?DateTime
  220.     {
  221.         return $this->createdAt;
  222.     }
  223.     /**
  224.      * @param DateTime|null $createdAt
  225.      */
  226.     public function setCreatedAt(?DateTime $createdAt): void
  227.     {
  228.         $this->createdAt $createdAt;
  229.     }
  230.     /**
  231.      * @return DateTime|null
  232.      */
  233.     public function getUpdatedAt(): ?DateTime
  234.     {
  235.         return $this->updatedAt;
  236.     }
  237.     /**
  238.      * @param DateTime|null $updatedAt
  239.      */
  240.     public function setUpdatedAt(?DateTime $updatedAt): void
  241.     {
  242.         $this->updatedAt $updatedAt;
  243.     }
  244.     /**
  245.      * @ORM\PrePersist
  246.      */
  247.     #[Ignore]
  248.     public function setCreatedAtValue(): void
  249.     {
  250.         $this->createdAt = new DateTime();
  251.     }
  252.     /**
  253.      * @ORM\PrePersist
  254.      * @ORM\PreUpdate
  255.      */
  256.     #[Ignore]
  257.     public function setUpdatedAtValue(): void
  258.     {
  259.         $this->updatedAt = new DateTime();
  260.     }
  261.     /**
  262.      * @return bool
  263.      */
  264.     public function isDisabled(): bool
  265.     {
  266.         return $this->disabled;
  267.     }
  268.     /**
  269.      * @param bool $disabled
  270.      */
  271.     public function setDisabled(bool $disabled): void
  272.     {
  273.         $this->disabled $disabled;
  274.     }
  275. }