<?php
namespace App\Entity;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Serializer\Annotation\Ignore;
/**
* @ORM\Entity(repositoryClass="App\Repository\ResidentRepository")
* @ORM\Table(name="residents")
* * @ORM\HasLifecycleCallbacks()
*/
class Resident implements UserInterface, PasswordAuthenticatedUserInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private int $id;
/**
* @ORM\Column(type="string", length=180, unique=true)
*/
private string $email;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private string|null $firstname;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private string|null $lastname;
/**
* @var array<string>
* @ORM\Column(type="json")
*/
private array $roles = [];
/**
* @var string The hashed password
* @ORM\Column(type="string")
*/
#[Ignore]
private string $password;
/**
* @var Collection<int, Flat>
* @ORM\OneToMany(targetEntity="App\Entity\Flat", mappedBy="resident")
*/
private Collection $flats;
/**
* @ORM\Column(type="string", length=12, nullable=true)
*/
private string|null $resetPasswordCode = null;
/**
* @ORM\Column(type="boolean")
*/
private bool $hasAcceptedTerms;
/**
* @ORM\Column(name="created_at", type="datetime")
*/
private DateTime|null $createdAt;
/**
* @ORM\Column(name="updated_at", type="datetime", nullable=true)
*/
private DateTime|null $updatedAt;
/**
* @ORM\Column(type="boolean")
*/
private bool $disabled = false;
public function __construct()
{
$this->flats = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): Resident
{
$this->email = $email;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUsername(): string
{
return (string) $this->email;
}
public function getRoles(): array
{
return $this->roles;
}
/**
* @param array<string> $roles
* @return $this
*/
public function setRoles(array $roles): Resident
{
$this->roles = $roles;
return $this;
}
/**
* @see UserInterface
*/
#[Ignore]
public function getPassword(): string
{
return (string) $this->password;
}
/**
* @param string $password
* @return Resident
*/
#[Ignore]
public function setPassword(string $password): Resident
{
$this->password = $password;
return $this;
}
/**
* @return Collection<int, Flat>
*/
public function getFlats(): Collection
{
return $this->flats;
}
public function addFlat(Flat $flat): Resident
{
if (!$this->flats->contains($flat)) {
$this->flats[] = $flat;
$flat->setResident($this);
}
return $this;
}
/**
* @param Collection<int, Flat> $flats
* @return $this
*/
public function setFlats(Collection $flats): Resident
{
foreach ($flats as $flat) {
if (!$this->flats->contains($flat)) {
$this->flats[] = $flat;
$flat->setResident($this);
}
}
return $this;
}
public function removeFlat(Flat $flat): Resident
{
if ($this->flats->removeElement($flat)) {
// set the owning side to null (unless already changed)
if ($flat->getResident() === $this) {
$flat->setResident(null);
}
}
return $this;
}
public function getHasAcceptedTerms(): ?bool
{
return $this->hasAcceptedTerms;
}
public function setHasAcceptedTerms(bool $hasAcceptedTerms): Resident
{
$this->hasAcceptedTerms = $hasAcceptedTerms;
return $this;
}
public function getFirstname(): ?string
{
return $this->firstname;
}
public function setFirstname(?string $firstname): Resident
{
$this->firstname = $firstname;
return $this;
}
public function getLastname(): ?string
{
return $this->lastname;
}
public function setLastname(?string $lastname): Resident
{
$this->lastname = $lastname;
return $this;
}
public function getUserIdentifier(): string
{
return $this->getEmail();
}
public function eraseCredentials(): void
{
// TODO: Implement eraseCredentials() method.
}
/**
* @return string|null
*/
public function getResetPasswordCode(): ?string
{
return $this->resetPasswordCode;
}
/**
* @param string|null $resetPasswordCode
*/
public function setResetPasswordCode(?string $resetPasswordCode): void
{
$this->resetPasswordCode = $resetPasswordCode;
}
/**
* @return DateTime|null
*/
public function getCreatedAt(): ?DateTime
{
return $this->createdAt;
}
/**
* @param DateTime|null $createdAt
*/
public function setCreatedAt(?DateTime $createdAt): void
{
$this->createdAt = $createdAt;
}
/**
* @return DateTime|null
*/
public function getUpdatedAt(): ?DateTime
{
return $this->updatedAt;
}
/**
* @param DateTime|null $updatedAt
*/
public function setUpdatedAt(?DateTime $updatedAt): void
{
$this->updatedAt = $updatedAt;
}
/**
* @ORM\PrePersist
*/
#[Ignore]
public function setCreatedAtValue(): void
{
$this->createdAt = new DateTime();
}
/**
* @ORM\PrePersist
* @ORM\PreUpdate
*/
#[Ignore]
public function setUpdatedAtValue(): void
{
$this->updatedAt = new DateTime();
}
/**
* @return bool
*/
public function isDisabled(): bool
{
return $this->disabled;
}
/**
* @param bool $disabled
*/
public function setDisabled(bool $disabled): void
{
$this->disabled = $disabled;
}
}