src/Entity/User.php line 15

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\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  9. use Symfony\Component\Security\Core\User\UserInterface;
  10. #[ORM\Entity(repositoryClassUserRepository::class)]
  11. class User implements UserInterfacePasswordAuthenticatedUserInterface
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\Column(length180uniquetrue)]
  18.     private ?string $email null;
  19.     #[ORM\Column]
  20.     private ?string $phone null;
  21.     #[ORM\Column]
  22.     private array $roles = [];
  23.     /**
  24.      * @var string The hashed password
  25.      */
  26.     #[ORM\Column]
  27.     private ?string $password null;
  28.     #[ORM\Column(length255)]
  29.     private ?string $firstname null;
  30.     #[ORM\Column(length255)]
  31.     private ?string $lastname null;
  32.     #[ORM\OneToOne(mappedBy'user'cascade: ['persist''remove'])]
  33.     private ?Card $card null;
  34.     #[ORM\OneToMany(mappedBy'user'targetEntityCouponUser::class)]
  35.     private Collection $coupon;
  36.     #[ORM\Column(length255)]
  37.     private ?string $slug null;
  38.     #[ORM\OneToMany(mappedBy'user'targetEntityTicketGratter::class)]
  39.     private Collection $ticketGratters;
  40.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  41.     private ?\DateTimeInterface $birthdate null;
  42.     public function __construct()
  43.     {
  44.         $this->coupon = new ArrayCollection();
  45.         $this->ticketGratters = new ArrayCollection();
  46.     }
  47.     public function getId(): ?int
  48.     {
  49.         return $this->id;
  50.     }
  51.     public function getPhone(): ?string
  52.     {
  53.         return $this->phone;
  54.     }
  55.     public function setPhone(?string $phone): void
  56.     {
  57.         $this->phone $phone;
  58.     }
  59.     public function getEmail(): ?string
  60.     {
  61.         return $this->email;
  62.     }
  63.     public function setEmail(string $email): static
  64.     {
  65.         $this->email $email;
  66.         return $this;
  67.     }
  68.     /**
  69.      * A visual identifier that represents this user.
  70.      *
  71.      * @see UserInterface
  72.      */
  73.     public function getUserIdentifier(): string
  74.     {
  75.         return (string) $this->email;
  76.     }
  77.     /**
  78.      * @see UserInterface
  79.      */
  80.     public function getRoles(): array
  81.     {
  82.         $roles $this->roles;
  83.         // guarantee every user at least has ROLE_USER
  84.         $roles[] = 'ROLE_USER';
  85.         return array_unique($roles);
  86.     }
  87.     public function setRoles(array $roles): static
  88.     {
  89.         $this->roles $roles;
  90.         return $this;
  91.     }
  92.     /**
  93.      * @see PasswordAuthenticatedUserInterface
  94.      */
  95.     public function getPassword(): string
  96.     {
  97.         return $this->password;
  98.     }
  99.     public function setPassword(string $password): static
  100.     {
  101.         $this->password $password;
  102.         return $this;
  103.     }
  104.     /**
  105.      * @see UserInterface
  106.      */
  107.     public function eraseCredentials(): void
  108.     {
  109.         // If you store any temporary, sensitive data on the user, clear it here
  110.         // $this->plainPassword = null;
  111.     }
  112.     public function getFirstname(): ?string
  113.     {
  114.         return ucwords($this->firstname);
  115.     }
  116.     public function setFirstname(string $firstname): static
  117.     {
  118.         $this->firstname $firstname;
  119.         return $this;
  120.     }
  121.     public function getLastname(): ?string
  122.     {
  123.         return ucwords($this->lastname);
  124.     }
  125.     public function getFullName(): ?string
  126.     {
  127.         return $this->getFirstname() . ' ' $this->getLastname();
  128.     }
  129.     public function setLastname(string $lastname): static
  130.     {
  131.         $this->lastname $lastname;
  132.         return $this;
  133.     }
  134.     public function getCard(): ?Card
  135.     {
  136.         return $this->card;
  137.     }
  138.     public function setCard(Card $card): static
  139.     {
  140.         // set the owning side of the relation if necessary
  141.         if ($card->getUser() !== $this) {
  142.             $card->setUser($this);
  143.         }
  144.         $this->card $card;
  145.         return $this;
  146.     }
  147.     /**
  148.      * @return Collection<int, CouponUser>
  149.      */
  150.     public function getCoupon(): Collection
  151.     {
  152.         return $this->coupon;
  153.     }
  154.     public function addCoupon(CouponUser $coupon): static
  155.     {
  156.         if (!$this->coupon->contains($coupon)) {
  157.             $this->coupon->add($coupon);
  158.             $coupon->setUser($this);
  159.         }
  160.         return $this;
  161.     }
  162.     public function removeCoupon(CouponUser $coupon): static
  163.     {
  164.         if ($this->coupon->removeElement($coupon)) {
  165.             // set the owning side to null (unless already changed)
  166.             if ($coupon->getUser() === $this) {
  167.                 $coupon->setUser(null);
  168.             }
  169.         }
  170.         return $this;
  171.     }
  172.     public function getSlug(): ?string
  173.     {
  174.         return $this->slug;
  175.     }
  176.     public function setSlug(string $slug): static
  177.     {
  178.         $this->slug $slug;
  179.         return $this;
  180.     }
  181.     /**
  182.      * @return Collection<int, TicketGratter>
  183.      */
  184.     public function getTicketGratters(): Collection
  185.     {
  186.         return $this->ticketGratters;
  187.     }
  188.     public function addTicketGratter(TicketGratter $ticketGratter): static
  189.     {
  190.         if (!$this->ticketGratters->contains($ticketGratter)) {
  191.             $this->ticketGratters->add($ticketGratter);
  192.             $ticketGratter->setUser($this);
  193.         }
  194.         return $this;
  195.     }
  196.     public function removeTicketGratter(TicketGratter $ticketGratter): static
  197.     {
  198.         if ($this->ticketGratters->removeElement($ticketGratter)) {
  199.             // set the owning side to null (unless already changed)
  200.             if ($ticketGratter->getUser() === $this) {
  201.                 $ticketGratter->setUser(null);
  202.             }
  203.         }
  204.         return $this;
  205.     }
  206.     public function getBirthdate(): ?\DateTimeInterface
  207.     {
  208.         return $this->birthdate;
  209.     }
  210.     public function setBirthdate(?\DateTimeInterface $birthdate): self
  211.     {
  212.         $this->birthdate $birthdate;
  213.         return $this;
  214.     }
  215. }