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\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Gedmo\Timestampable\Traits\TimestampableEntity;
  9. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  10. use Symfony\Component\Security\Core\User\UserInterface;
  11. #[ORM\Entity(UserRepository::class)]
  12. #[ORM\Table('`user`')]
  13. class User implements UserInterfacePasswordAuthenticatedUserInterface
  14. {
  15.     use TimestampableEntity;
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue]
  18.     #[ORM\Column]
  19.     private ?int $id;
  20.     #[ORM\Column(length180nullabletrue)]
  21.     private ?string $email;
  22.     #[ORM\Column(typeTypes::JSON)]
  23.     private array $roles = [];
  24.     /**
  25.      * The hashed password
  26.      */
  27.     #[ORM\Column]
  28.     private ?string $password;
  29.     /**
  30.      * The plain non-persisted password
  31.      */
  32.     private ?string $plainPassword;
  33.     #[ORM\Column]
  34.     private bool $enabled true;
  35.     #[ORM\Column]
  36.     private ?string $firstName;
  37.     #[ORM\Column]
  38.     private ?string $lastName;
  39.     #[ORM\Column(nullabletrue)]
  40.     private ?string $avatar;
  41.     #[ORM\OneToMany('askedBy'Question::class)]
  42.     private Collection $questions;
  43.     #[ORM\OneToMany('answeredBy'Answer::class)]
  44.     private Collection $answers;
  45.     #[ORM\OneToMany(mappedBy'vergunning_medewerker'targetEntityOrder::class)]
  46.     private Collection $orders;
  47.     #[ORM\Column(length255)]
  48.     private ?string $username null;
  49.     #[ORM\OneToMany(mappedBy'offerte_medewerker'targetEntityOrder::class)]
  50.     private Collection $orderss;
  51.     #[ORM\OneToMany(mappedBy'afhaler_contactmedewerker'targetEntityOrder::class)]
  52.     private Collection $orders_afhaler_contactmedewerker;
  53.     #[ORM\OneToMany(mappedBy'user'targetEntityReminder::class)]
  54.     private Collection $reminders;
  55.     public function __construct()
  56.     {
  57.         $this->questions = new ArrayCollection();
  58.         $this->answers = new ArrayCollection();
  59.         $this->orders = new ArrayCollection();
  60.         $this->orderss = new ArrayCollection();
  61.         $this->orders_afhaler_contactmedewerker = new ArrayCollection();
  62.         $this->reminders = new ArrayCollection();
  63.     }
  64.     public function __toString()
  65.     {
  66.         return $this->getFullName();
  67.     }
  68.     public function getId(): ?int
  69.     {
  70.         return $this->id;
  71.     }
  72.     public function getEmail(): ?string
  73.     {
  74.         return $this->email;
  75.     }
  76.     public function setEmail(string $email): self
  77.     {
  78.         $this->email $email;
  79.         return $this;
  80.     }
  81.     /**
  82.      * A visual identifier that represents this user.
  83.      *
  84.      * @see UserInterface
  85.      */
  86.     public function getUserIdentifier(): string
  87.     {
  88.         return (string) $this->username;
  89.     }
  90.     /**
  91.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  92.      */
  93.     public function getUsername(): string
  94.     {
  95.         return (string) $this->username;
  96.     }
  97.     public function getRoles(): array
  98.     {
  99.         return $this->roles;
  100.     }
  101.     public function setRoles(array $roles): self
  102.     {
  103.         $this->roles $roles;
  104.         return $this;
  105.     }
  106.     public function getPassword(): ?string
  107.     {
  108.         return $this->password;
  109.     }
  110.     public function setPassword(string $password): self
  111.     {
  112.         $this->password $password;
  113.         
  114.         return $this;
  115.     }
  116.     public function getPlainPassword(): string
  117.     {
  118.         return $this->plainPassword;
  119.     }
  120.    
  121.     public function issetPlainPassword(): bool
  122.     {
  123.         if(isset ($this->plainPassword)){
  124.             return true;
  125.         };
  126.         return false;
  127.     }
  128.     
  129.     public function setPlainPassword(string $plainPassword): void
  130.     {
  131.         $this->plainPassword $plainPassword;
  132.     }
  133.     /**
  134.      * Returning a salt is only needed, if you are not using a modern
  135.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  136.      *
  137.      * @see UserInterface
  138.      */
  139.     public function getSalt(): ?string
  140.     {
  141.         return null;
  142.     }
  143.     /**
  144.      * @see UserInterface
  145.      */
  146.     public function eraseCredentials()
  147.     {
  148.         // If you store any temporary, sensitive data on the user, clear it here
  149.          $this->plainPassword null;
  150.     }
  151.     public function isEnabled(): ?bool
  152.     {
  153.         return $this->enabled;
  154.     }
  155.     public function setEnabled(bool $enabled): self
  156.     {
  157.         $this->enabled $enabled;
  158.         return $this;
  159.     }
  160.     public function getFirstName(): ?string
  161.     {
  162.         return $this->firstName;
  163.     }
  164.     public function setFirstName(string $firstName): self
  165.     {
  166.         $this->firstName $firstName;
  167.         return $this;
  168.     }
  169.     public function getLastName(): ?string
  170.     {
  171.         return $this->lastName;
  172.     }
  173.     public function setLastName(string $lastName): self
  174.     {
  175.         $this->lastName $lastName;
  176.         return $this;
  177.     }
  178.     public function getFullName(): ?string
  179.     {
  180.         return $this->firstName.' '.$this->lastName;
  181.     }
  182.     public function getAvatar(): ?string
  183.     {
  184.         return $this->avatar;
  185.     }
  186.     public function getAvatarUrl(): ?string
  187.     {
  188.         if (!$this->avatar) {
  189.             return null;
  190.         }
  191.         if (strpos($this->avatar'/') !== false) {
  192.             return $this->avatar;
  193.         }
  194.         return sprintf('/uploads/avatars/%s'$this->avatar);
  195.     }
  196.     public function setAvatar(?string $avatar): self
  197.     {
  198.         $this->avatar $avatar;
  199.         return $this;
  200.     }
  201.     /**
  202.      * @return Collection<int, Question>
  203.      */
  204.     public function getQuestions(): Collection
  205.     {
  206.         return $this->questions;
  207.     }
  208.     public function addQuestion(Question $question): self
  209.     {
  210.         if (!$this->questions->contains($question)) {
  211.             $this->questions->add($question);
  212.             $question->setAskedBy($this);
  213.         }
  214.         return $this;
  215.     }
  216.     public function removeQuestion(Question $question): self
  217.     {
  218.         if ($this->questions->removeElement($question)) {
  219.             // set the owning side to null (unless already changed)
  220.             if ($question->getAskedBy() === $this) {
  221.                 $question->setAskedBy(null);
  222.             }
  223.         }
  224.         return $this;
  225.     }
  226.     /**
  227.      * @return Collection<int, Answer>
  228.      */
  229.     public function getAnswers(): Collection
  230.     {
  231.         return $this->answers;
  232.     }
  233.     public function addAnswer(Answer $answer): self
  234.     {
  235.         if (!$this->answers->contains($answer)) {
  236.             $this->answers->add($answer);
  237.             $answer->setAnsweredBy($this);
  238.         }
  239.         return $this;
  240.     }
  241.     public function removeAnswer(Answer $answer): self
  242.     {
  243.         if ($this->answers->removeElement($answer)) {
  244.             // set the owning side to null (unless already changed)
  245.             if ($answer->getAnsweredBy() === $this) {
  246.                 $answer->setAnsweredBy(null);
  247.             }
  248.         }
  249.         return $this;
  250.     }
  251.     /**
  252.      * @return Collection<int, Order>
  253.      */
  254.     public function getOrders(): Collection
  255.     {
  256.         return $this->orders;
  257.     }
  258.     public function addOrder(Order $order): self
  259.     {
  260.         if (!$this->orders->contains($order)) {
  261.             $this->orders->add($order);
  262.             $order->setVergunningMedewerker($this);
  263.         }
  264.         return $this;
  265.     }
  266.     public function removeOrder(Order $order): self
  267.     {
  268.         if ($this->orders->removeElement($order)) {
  269.             // set the owning side to null (unless already changed)
  270.             if ($order->getVergunningMedewerker() === $this) {
  271.                 $order->setVergunningMedewerker(null);
  272.             }
  273.         }
  274.         return $this;
  275.     }
  276.     public function setUsername(string $username): self
  277.     {
  278.         $this->username $username;
  279.         return $this;
  280.     }
  281.     /**
  282.      * @return Collection<int, Order>
  283.      */
  284.     public function getOrderss(): Collection
  285.     {
  286.         return $this->orderss;
  287.     }
  288.     public function addOrderss(Order $orderss): self
  289.     {
  290.         if (!$this->orderss->contains($orderss)) {
  291.             $this->orderss->add($orderss);
  292.             $orderss->setOfferteMedewerker($this);
  293.         }
  294.         return $this;
  295.     }
  296.     public function removeOrderss(Order $orderss): self
  297.     {
  298.         if ($this->orderss->removeElement($orderss)) {
  299.             // set the owning side to null (unless already changed)
  300.             if ($orderss->getOfferteMedewerker() === $this) {
  301.                 $orderss->setOfferteMedewerker(null);
  302.             }
  303.         }
  304.         return $this;
  305.     }
  306.     /**
  307.      * @return Collection<int, Order>
  308.      */
  309.     public function getOrdersAfhalerContactmedewerker(): Collection
  310.     {
  311.         return $this->orders_afhaler_contactmedewerker;
  312.     }
  313.     public function addOrdersAfhalerContactmedewerker(Order $ordersAfhalerContactmedewerker): self
  314.     {
  315.         if (!$this->orders_afhaler_contactmedewerker->contains($ordersAfhalerContactmedewerker)) {
  316.             $this->orders_afhaler_contactmedewerker->add($ordersAfhalerContactmedewerker);
  317.             $ordersAfhalerContactmedewerker->setAfhalerContactmedewerker($this);
  318.         }
  319.         return $this;
  320.     }
  321.     public function removeOrdersAfhalerContactmedewerker(Order $ordersAfhalerContactmedewerker): self
  322.     {
  323.         if ($this->orders_afhaler_contactmedewerker->removeElement($ordersAfhalerContactmedewerker)) {
  324.             // set the owning side to null (unless already changed)
  325.             if ($ordersAfhalerContactmedewerker->getAfhalerContactmedewerker() === $this) {
  326.                 $ordersAfhalerContactmedewerker->setAfhalerContactmedewerker(null);
  327.             }
  328.         }
  329.         return $this;
  330.     }
  331.     /**
  332.      * @return Collection<int, Reminder>
  333.      */
  334.     public function getReminders(): Collection
  335.     {
  336.         return $this->reminders;
  337.     }
  338.     public function addReminder(Reminder $reminder): self
  339.     {
  340.         if (!$this->reminders->contains($reminder)) {
  341.             $this->reminders->add($reminder);
  342.             $reminder->setUser($this);
  343.         }
  344.         return $this;
  345.     }
  346.     public function removeReminder(Reminder $reminder): self
  347.     {
  348.         if ($this->reminders->removeElement($reminder)) {
  349.             // set the owning side to null (unless already changed)
  350.             if ($reminder->getUser() === $this) {
  351.                 $reminder->setUser(null);
  352.             }
  353.         }
  354.         return $this;
  355.     }
  356. }