src/Entity/User.php line 16

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. use Symfony\Component\Validator\Constraints as Assert;
  11. #[ORM\Entity(repositoryClassUserRepository::class)]
  12. #[UniqueEntity(fields: ['email'], message'There is already an account with this email')]
  13. class User implements UserInterfacePasswordAuthenticatedUserInterface
  14. {
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column(type'integer')]
  18.     private $id;
  19.     #[Assert\Email(
  20.         message'Die E-Mail {{ value }} ist keine gültige E-Mail.',
  21.     )]
  22.     #[ORM\Column(type'string'length180uniquetruenullabletrue)]
  23.     private $email;
  24.     #[ORM\Column(type'json')]
  25.     private $roles = [];
  26.     #[ORM\Column(type'string'nullabletrue)]
  27.     private $password;
  28.     #[ORM\Column(type'string'length255)]
  29.     private $firstName;
  30.     #[ORM\Column(type'string'length255)]
  31.     private $lastName;
  32.     #[ORM\Column(type'string'length255)]
  33.     private $street;
  34.     #[ORM\Column(type'integer')]
  35.     private $postCode;
  36.     #[ORM\Column(type'string'length255)]
  37.     private $city;
  38.     #[ORM\Column(type'string'length255)]
  39.     private $country;
  40.     #[ORM\Column(type'string'length255nullabletrue)]
  41.     private $phoneNumber;
  42.     #[ORM\Column(type'integer')]
  43.     private $gender;
  44.     #[ORM\Column(type'date')]
  45.     private $birthDate;
  46.     #[ORM\Column(type'string'length22nullabletrue)]
  47.     private $iban;
  48.     #[ORM\Column(type'string'length11nullabletrue)]
  49.     private $bic;
  50.     #[ORM\Column(type'string'length255nullabletrue)]
  51.     private $bank;
  52.     #[ORM\Column(type'string'length255nullabletrue)]
  53.     private $accountOwner;
  54.     #[ORM\OneToMany(mappedBy'user'targetEntitySkiUser::class)]
  55.     private $SkiClubUser;
  56.     #[ORM\Column(type'integer'nullabletrue)]
  57.     private $skiClubId;
  58.     #[ORM\Column(type'boolean')]
  59.     private $isVerified false;
  60.     #[ORM\OneToMany(mappedBy'user'targetEntityBooking::class)]
  61.     private $booking;
  62.     #[ORM\OneToMany(mappedBy'user'targetEntityBookingUser::class)]
  63.     private $bookingUser;
  64.     #[ORM\OneToMany(mappedBy'user'targetEntitySendMessages::class)]
  65.     private $sendMessage;
  66.     #[ORM\ManyToOne(targetEntityself::class, inversedBy'subUser')]
  67.     private $MainUser;
  68.     #[ORM\OneToMany(mappedBy'MainUser'targetEntityself::class)]
  69.     private $subUser;
  70.     #[ORM\OneToMany(mappedBy'supervisor'targetEntityTrip::class)]
  71.     private $supervisor;
  72.     #[ORM\OneToMany(mappedBy'recreationLeader'targetEntityTrip::class)]
  73.     private $recreationLeader;
  74.     #[ORM\ManyToMany(targetEntityTrip::class, inversedBy'users')]
  75.     private $SupervisorTrip;
  76.     public function __construct()
  77.     {
  78.         $this->SkiClubUser = new ArrayCollection();
  79.         $this->booking = new ArrayCollection();
  80.         $this->bookingUser = new ArrayCollection();
  81.         $this->sendMessage = new ArrayCollection();
  82.         $this->subUser = new ArrayCollection();
  83.         $this->supervisor = new ArrayCollection();
  84.         $this->recreationLeader = new ArrayCollection();
  85.         $this->SupervisorTrip = new ArrayCollection();
  86.     }
  87.     public function __toString()
  88.     {
  89.         return $this->getFirstName() . ' ' $this->getLastName();
  90.     }
  91.     public function nameString()
  92.     {
  93.         return $this->getFirstName() . ' ' $this->getLastName();
  94.     }
  95.     public function getId(): ?int
  96.     {
  97.         return $this->id;
  98.     }
  99.     public function getEmail(): ?string
  100.     {
  101.         return $this->email;
  102.     }
  103.     public function setEmail(string $email): self
  104.     {
  105.         $this->email $email;
  106.         return $this;
  107.     }
  108.     /**
  109.      * A visual identifier that represents this user.
  110.      *
  111.      * @see UserInterface
  112.      */
  113.     public function getUserIdentifier(): string
  114.     {
  115.         return (string)$this->email;
  116.     }
  117.     /**
  118.      * @see UserInterface
  119.      */
  120.     public function getRoles(): array
  121.     {
  122.         $roles $this->roles;
  123.         // guarantee every user at least has ROLE_USER
  124.         $roles[] = 'ROLE_USER';
  125.         return array_unique($roles);
  126.     }
  127.     /**
  128.      * @see UserInterface
  129.      */
  130.     public function getHighestRole(): string
  131.     {
  132.         // jeder Nutzer kann nur eine Rolle haben daher [0]
  133.         return $this->getRoles()[0];
  134.     }
  135.     /**
  136.      * @see UserInterface
  137.      */
  138.     public function getHighestRoleName(): string
  139.     {
  140.         if ($this->getHighestRole() == 'ROLE_USER') {
  141.             return 'Standardnutzer';
  142.         }
  143.         return ucfirst(strtolower(substr($this->getHighestRole(), 5)));
  144.     }
  145.     public function setRoles(array $roles): self
  146.     {
  147.         $this->roles $roles;
  148.         return $this;
  149.     }
  150.     /**
  151.      * @see PasswordAuthenticatedUserInterface
  152.      */
  153.     public function getPassword(): string
  154.     {
  155.         return $this->password;
  156.     }
  157.     public function setPassword(string $password): self
  158.     {
  159.         $this->password $password;
  160.         return $this;
  161.     }
  162.     /**
  163.      * @see UserInterface
  164.      */
  165.     public function eraseCredentials()
  166.     {
  167.         // If you store any temporary, sensitive data on the user, clear it here
  168.         // $this->plainPassword = null;
  169.     }
  170.     public function getFirstName(): ?string
  171.     {
  172.         return $this->firstName;
  173.     }
  174.     public function setFirstName(string $firstName): self
  175.     {
  176.         $this->firstName $firstName;
  177.         return $this;
  178.     }
  179.     public function getLastName(): ?string
  180.     {
  181.         return $this->lastName;
  182.     }
  183.     public function setLastName(string $lastName): self
  184.     {
  185.         $this->lastName $lastName;
  186.         return $this;
  187.     }
  188.     public function getStreet(): ?string
  189.     {
  190.         return $this->street;
  191.     }
  192.     public function setStreet(string $street): self
  193.     {
  194.         $this->street $street;
  195.         return $this;
  196.     }
  197.     public function getPostCode(): ?int
  198.     {
  199.         return $this->postCode;
  200.     }
  201.     public function setPostCode(int $postCode): self
  202.     {
  203.         $this->postCode $postCode;
  204.         return $this;
  205.     }
  206.     public function getCity(): ?string
  207.     {
  208.         return $this->city;
  209.     }
  210.     public function setCity(string $city): self
  211.     {
  212.         $this->city $city;
  213.         return $this;
  214.     }
  215.     public function getCountry(): ?string
  216.     {
  217.         return $this->country;
  218.     }
  219.     public function setCountry(string $country): self
  220.     {
  221.         $this->country $country;
  222.         return $this;
  223.     }
  224.     public function getPhoneNumber(): ?string
  225.     {
  226.         return $this->phoneNumber;
  227.     }
  228.     public function setPhoneNumber(?string $phoneNumber): self
  229.     {
  230.         $this->phoneNumber $phoneNumber;
  231.         return $this;
  232.     }
  233.     public function getGender(): ?int
  234.     {
  235.         return $this->gender;
  236.     }
  237.     public function setGender(int $gender): self
  238.     {
  239.         $this->gender $gender;
  240.         return $this;
  241.     }
  242.     public function getBirthDate(): ?\DateTimeInterface
  243.     {
  244.         return $this->birthDate;
  245.     }
  246.     public function setBirthDate(\DateTimeInterface $birthDate): self
  247.     {
  248.         $this->birthDate $birthDate;
  249.         return $this;
  250.     }
  251.     public function getIban(): ?string
  252.     {
  253.         return $this->iban;
  254.     }
  255.     public function setIban(string $iban): self
  256.     {
  257.         $this->iban $iban;
  258.         return $this;
  259.     }
  260.     public function getBic(): ?string
  261.     {
  262.         return $this->bic;
  263.     }
  264.     public function setBic(?string $bic): self
  265.     {
  266.         $this->bic $bic;
  267.         return $this;
  268.     }
  269.     public function getBank(): ?string
  270.     {
  271.         return $this->bank;
  272.     }
  273.     public function setBank(string $bank): self
  274.     {
  275.         $this->bank $bank;
  276.         return $this;
  277.     }
  278.     public function getAccountOwner(): ?string
  279.     {
  280.         return $this->accountOwner;
  281.     }
  282.     public function setAccountOwner(string $accountOwner): self
  283.     {
  284.         $this->accountOwner $accountOwner;
  285.         return $this;
  286.     }
  287.     /**
  288.      * @return Collection<int, SkiUser>
  289.      */
  290.     public function getSkiClubUser(): Collection
  291.     {
  292.         return $this->SkiClubUser;
  293.     }
  294.     public function addSkiClubUser(SkiUser $skiClubUser): self
  295.     {
  296.         if (!$this->SkiClubUser->contains($skiClubUser)) {
  297.             $this->SkiClubUser[] = $skiClubUser;
  298.             $skiClubUser->setUser($this);
  299.         }
  300.         return $this;
  301.     }
  302.     public function removeSkiClubUser(SkiUser $skiClubUser): self
  303.     {
  304.         if ($this->SkiClubUser->removeElement($skiClubUser)) {
  305.             // set the owning side to null (unless already changed)
  306.             if ($skiClubUser->getUser() === $this) {
  307.                 $skiClubUser->setUser(null);
  308.             }
  309.         }
  310.         return $this;
  311.     }
  312.     public function getSkiClubId(): ?int
  313.     {
  314.         return $this->skiClubId;
  315.     }
  316.     public function setSkiClubId(?int $skiClubId): self
  317.     {
  318.         $this->skiClubId $skiClubId;
  319.         return $this;
  320.     }
  321.     public function getIsVerified(): ?bool
  322.     {
  323.         return $this->isVerified;
  324.     }
  325.     public function setIsVerified(bool $isVerified): self
  326.     {
  327.         $this->isVerified $isVerified;
  328.         return $this;
  329.     }
  330.     /**
  331.      * @return Collection<int, Booking>
  332.      */
  333.     public function getBooking(): Collection
  334.     {
  335.         return $this->booking;
  336.     }
  337.     public function addBooking(Booking $booking): self
  338.     {
  339.         if (!$this->booking->contains($booking)) {
  340.             $this->booking[] = $booking;
  341.             $booking->setUser($this);
  342.         }
  343.         return $this;
  344.     }
  345.     public function removeBooking(Booking $booking): self
  346.     {
  347.         if ($this->booking->removeElement($booking)) {
  348.             // set the owning side to null (unless already changed)
  349.             if ($booking->getUser() === $this) {
  350.                 $booking->setUser(null);
  351.             }
  352.         }
  353.         return $this;
  354.     }
  355.     /**
  356.      * @return Collection<int, BookingUser>
  357.      */
  358.     public function getBookingUser(): Collection
  359.     {
  360.         return $this->bookingUser;
  361.     }
  362.     public function addBookingUser(BookingUser $bookingUser): self
  363.     {
  364.         if (!$this->bookingUser->contains($bookingUser)) {
  365.             $this->bookingUser[] = $bookingUser;
  366.             $bookingUser->setUser($this);
  367.         }
  368.         return $this;
  369.     }
  370.     public function removeBookingUser(BookingUser $bookingUser): self
  371.     {
  372.         if ($this->bookingUser->removeElement($bookingUser)) {
  373.             // set the owning side to null (unless already changed)
  374.             if ($bookingUser->getUser() === $this) {
  375.                 $bookingUser->setUser(null);
  376.             }
  377.         }
  378.         return $this;
  379.     }
  380.     /**
  381.      * @return Collection<int, SendMessages>
  382.      */
  383.     public function getSendMessage(): Collection
  384.     {
  385.         return $this->sendMessage;
  386.     }
  387.     public function addSendMassage(SendMessages $sendMessage): self
  388.     {
  389.         if (!$this->sendMessage->contains($sendMessage)) {
  390.             $this->sendMessage[] = $sendMessage;
  391.             $sendMessage->setUser($this);
  392.         }
  393.         return $this;
  394.     }
  395.     public function removeSendMessage(SendMessages $sendMessage): self
  396.     {
  397.         if ($this->sendMessage->removeElement($sendMessage)) {
  398.             // set the owning side to null (unless already changed)
  399.             if ($sendMessage->getUser() === $this) {
  400.                 $sendMessage->setUser(null);
  401.             }
  402.         }
  403.         return $this;
  404.     }
  405.     public function getMainUser(): ?self
  406.     {
  407.         return $this->MainUser;
  408.     }
  409.     public function setMainUser(?self $MainUser): self
  410.     {
  411.         $this->MainUser $MainUser;
  412.         return $this;
  413.     }
  414.     /**
  415.      * @return Collection<int, self>
  416.      */
  417.     public function getSubUser(): Collection
  418.     {
  419.         return $this->subUser;
  420.     }
  421.     public function addSubUser(self $subUser): self
  422.     {
  423.         if (!$this->subUser->contains($subUser)) {
  424.             $this->subUser[] = $subUser;
  425.             $subUser->setMainUser($this);
  426.         }
  427.         return $this;
  428.     }
  429.     public function removeSubUser(self $subUser): self
  430.     {
  431.         if ($this->subUser->removeElement($subUser)) {
  432.             // set the owning side to null (unless already changed)
  433.             if ($subUser->getMainUser() === $this) {
  434.                 $subUser->setMainUser(null);
  435.             }
  436.         }
  437.         return $this;
  438.     }
  439.     /**
  440.      * @return Collection<int, Trip>
  441.      */
  442.     public function getSupervisor(): Collection
  443.     {
  444.         return $this->supervisor;
  445.     }
  446.     public function addSupervisor(Trip $supervisor): self
  447.     {
  448.         if (!$this->supervisor->contains($supervisor)) {
  449.             $this->supervisor[] = $supervisor;
  450.             $supervisor->setSupervisor($this);
  451.         }
  452.         return $this;
  453.     }
  454.     public function removeSupervisor(Trip $supervisor): self
  455.     {
  456.         if ($this->supervisor->removeElement($supervisor)) {
  457.             // set the owning side to null (unless already changed)
  458.             if ($supervisor->getSupervisor() === $this) {
  459.                 $supervisor->setSupervisor(null);
  460.             }
  461.         }
  462.         return $this;
  463.     }
  464.     /**
  465.      * @return Collection<int, Trip>
  466.      */
  467.     public function getRecreationLeader(): Collection
  468.     {
  469.         return $this->recreationLeader;
  470.     }
  471.     public function addRecreationLeader(Trip $recreationLeader): self
  472.     {
  473.         if (!$this->recreationLeader->contains($recreationLeader)) {
  474.             $this->recreationLeader[] = $recreationLeader;
  475.             $recreationLeader->setRecreationLeader($this);
  476.         }
  477.         return $this;
  478.     }
  479.     public function removeRecreationLeader(Trip $recreationLeader): self
  480.     {
  481.         if ($this->recreationLeader->removeElement($recreationLeader)) {
  482.             // set the owning side to null (unless already changed)
  483.             if ($recreationLeader->getRecreationLeader() === $this) {
  484.                 $recreationLeader->setRecreationLeader(null);
  485.             }
  486.         }
  487.         return $this;
  488.     }
  489.     /**
  490.      * @return Collection<int, Trip>
  491.      */
  492.     public function getSupervisorTrip(): Collection
  493.     {
  494.         return $this->SupervisorTrip;
  495.     }
  496.     public function addSupervisorTrip(Trip $supervisorTrip): self
  497.     {
  498.         if (!$this->SupervisorTrip->contains($supervisorTrip)) {
  499.             $this->SupervisorTrip[] = $supervisorTrip;
  500.         }
  501.         return $this;
  502.     }
  503.     public function removeSupervisorTrip(Trip $supervisorTrip): self
  504.     {
  505.         $this->SupervisorTrip->removeElement($supervisorTrip);
  506.         return $this;
  507.     }
  508. }