src/Entity/User.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Interfaces\HotelUserInterface;
  4. use App\Repository\UserRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  10. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  11. use Symfony\Component\Security\Core\User\UserInterface;
  12. #[ORM\Entity(repositoryClassUserRepository::class)]
  13. #[ORM\Table(name'`user`')]
  14. #[UniqueEntity(fields: ['email'], message'There is already an account with this email')]
  15. #[UniqueEntity(fields: ['email'], message'There is already an account with this email')]
  16. class User implements HotelUserInterfacePasswordAuthenticatedUserInterface
  17. {
  18.     #[ORM\Id]
  19.     #[ORM\GeneratedValue]
  20.     #[ORM\Column]
  21.     private ?int $id null;
  22.     #[ORM\Column(length180uniquetrue)]
  23.     private ?string $email null;
  24.     #[ORM\Column(length180nullabletrue)]
  25.     private ?string $username null;
  26.     #[ORM\Column]
  27.     private array $roles = [];
  28.     /**
  29.      * @var string The hashed password
  30.      */
  31.     #[ORM\Column]
  32.     private ?string $password null;
  33.     #[ORM\Column(type'boolean')]
  34.     private $isVerified false;
  35.     #[ORM\OneToMany(mappedBy'hotelUser'targetEntityOrder::class)]
  36.     private Collection $orders;
  37.     #[ORM\Column(length255nullabletrue)]
  38.     private ?string $firstName null;
  39.     #[ORM\Column(length255nullabletrue)]
  40.     private ?string $lastName null;
  41.     #[ORM\Column(length255nullabletrue)]
  42.     private ?string $mobile null;
  43.     #[ORM\ManyToOne(cascade: ['persist''remove'])]
  44.     private ?Gender $gender null;
  45.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  46.     private ?\DateTimeInterface $birthdate null;
  47.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  48.     private ?string $address null;
  49.     #[ORM\Column(length255nullabletrue)]
  50.     private ?string $avatar null;
  51.     #[ORM\ManyToOne]
  52.     private ?Country $country null;
  53.     public function __construct()
  54.     {
  55.         $this->orders = new ArrayCollection();
  56.     }
  57.     public function getId(): ?int
  58.     {
  59.         return $this->id;
  60.     }
  61.     public function getEmail(): ?string
  62.     {
  63.         return $this->email;
  64.     }
  65.     public function setEmail(string $email): self
  66.     {
  67.         $this->email $email;
  68.         return $this;
  69.     }
  70.     public function getUsername(): ?string{
  71.         return  $this->username;
  72.     }
  73.     public function setUsername(string $username)
  74.     {
  75.         $this->username $username;
  76.         return $this;
  77.     }
  78.     /**
  79.      * A visual identifier that represents this user.
  80.      *
  81.      * @see UserInterface
  82.      */
  83.     public function getUserIdentifier(): string
  84.     {
  85.         return (string) $this->email;
  86.     }
  87.     /**
  88.      * @see UserInterface
  89.      */
  90.     public function getRoles(): array
  91.     {
  92.         $roles $this->roles;
  93.         // guarantee every user at least has ROLE_USER
  94.         $roles[] = 'ROLE_USER';
  95.         return array_unique($roles);
  96.     }
  97.     public function setRoles(array $roles): self
  98.     {
  99.         $this->roles $roles;
  100.         return $this;
  101.     }
  102.     /**
  103.      * @see PasswordAuthenticatedUserInterface
  104.      */
  105.     public function getPassword(): string
  106.     {
  107.         return $this->password;
  108.     }
  109.     public function setPassword(string $password): self
  110.     {
  111.         $this->password $password;
  112.         return $this;
  113.     }
  114.     /**
  115.      * @see UserInterface
  116.      */
  117.     public function eraseCredentials()
  118.     {
  119.         // If you store any temporary, sensitive data on the user, clear it here
  120.         // $this->plainPassword = null;
  121.     }
  122.     public function isVerified(): bool
  123.     {
  124.         return $this->isVerified;
  125.     }
  126.     public function setIsVerified(bool $isVerified): self
  127.     {
  128.         $this->isVerified $isVerified;
  129.         return $this;
  130.     }
  131.     /**
  132.      * @return Collection<int, Order>
  133.      */
  134.     public function getOrders(): Collection
  135.     {
  136.         return $this->orders;
  137.     }
  138.     public function addOrder(Order $order): self
  139.     {
  140.         if (!$this->orders->contains($order)) {
  141.             $this->orders->add($order);
  142.             $order->setHotelUser($this);
  143.         }
  144.         return $this;
  145.     }
  146.     public function removeOrder(Order $order): self
  147.     {
  148.         if ($this->orders->removeElement($order)) {
  149.             // set the owning side to null (unless already changed)
  150.             if ($order->getHotelUser() === $this) {
  151.                 $order->setHotelUser(null);
  152.             }
  153.         }
  154.         return $this;
  155.     }
  156.     public function getFirstName(): ?string
  157.     {
  158.         return $this->firstName;
  159.     }
  160.     public function setFirstName(?string $firstName): self
  161.     {
  162.         $this->firstName $firstName;
  163.         return $this;
  164.     }
  165.     public function getLastName(): ?string
  166.     {
  167.         return $this->lastName;
  168.     }
  169.     public function setLastName(?string $lastName): self
  170.     {
  171.         $this->lastName $lastName;
  172.         return $this;
  173.     }
  174.     public function getMobile(): ?string
  175.     {
  176.         return $this->mobile;
  177.     }
  178.     public function setMobile(?string $mobile): self
  179.     {
  180.         $this->mobile $mobile;
  181.         return $this;
  182.     }
  183.     public function getGender(): ?Gender
  184.     {
  185.         return $this->gender;
  186.     }
  187.     public function setGender(?Gender $gender): self
  188.     {
  189.         $this->gender $gender;
  190.         return $this;
  191.     }
  192.     public function getBirthdate(): ?\DateTimeInterface
  193.     {
  194.         return $this->birthdate;
  195.     }
  196.     public function setBirthdate(?\DateTimeInterface $birthdate): self
  197.     {
  198.         $this->birthdate $birthdate;
  199.         return $this;
  200.     }
  201.     public function getAddress(): ?string
  202.     {
  203.         return $this->address;
  204.     }
  205.     public function setAddress(?string $address): self
  206.     {
  207.         $this->address $address;
  208.         return $this;
  209.     }
  210.     public function getAvatar(): ?string
  211.     {
  212.         return $this->avatar;
  213.     }
  214.     public function setAvatar(?string $avatar): self
  215.     {
  216.         $this->avatar $avatar;
  217.         return $this;
  218.     }
  219.     public function getCountry(): ?Country
  220.     {
  221.         return $this->country;
  222.     }
  223.     public function setCountry(?Country $country): self
  224.     {
  225.         $this->country $country;
  226.         return $this;
  227.     }
  228. }