<?php
namespace App\Entity;
use App\Repository\UserRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
#[ORM\Entity(UserRepository::class)]
#[ORM\Table('`user`')]
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
use TimestampableEntity;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id;
#[ORM\Column(length: 180, nullable: true)]
private ?string $email;
#[ORM\Column(type: Types::JSON)]
private array $roles = [];
/**
* The hashed password
*/
#[ORM\Column]
private ?string $password;
/**
* The plain non-persisted password
*/
private ?string $plainPassword;
#[ORM\Column]
private bool $enabled = true;
#[ORM\Column]
private ?string $firstName;
#[ORM\Column]
private ?string $lastName;
#[ORM\Column(nullable: true)]
private ?string $avatar;
#[ORM\OneToMany('askedBy', Question::class)]
private Collection $questions;
#[ORM\OneToMany('answeredBy', Answer::class)]
private Collection $answers;
#[ORM\OneToMany(mappedBy: 'vergunning_medewerker', targetEntity: Order::class)]
private Collection $orders;
#[ORM\Column(length: 255)]
private ?string $username = null;
#[ORM\OneToMany(mappedBy: 'offerte_medewerker', targetEntity: Order::class)]
private Collection $orderss;
#[ORM\OneToMany(mappedBy: 'afhaler_contactmedewerker', targetEntity: Order::class)]
private Collection $orders_afhaler_contactmedewerker;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: Reminder::class)]
private Collection $reminders;
#[ORM\ManyToMany(targetEntity: Groep::class, mappedBy: 'users')]
private Collection $groepen;
#[ORM\OneToMany(mappedBy: 'ingevoerd_door', targetEntity: Reminder::class)]
private Collection $created_reminders;
public function __construct()
{
$this->questions = new ArrayCollection();
$this->answers = new ArrayCollection();
$this->orders = new ArrayCollection();
$this->orderss = new ArrayCollection();
$this->orders_afhaler_contactmedewerker = new ArrayCollection();
$this->reminders = new ArrayCollection();
$this->groepen = new ArrayCollection();
$this->created_reminders = new ArrayCollection();
}
public function __toString()
{
return $this->getFullName();
}
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return (string) $this->username;
}
/**
* @deprecated since Symfony 5.3, use getUserIdentifier instead
*/
public function getUsername(): string
{
return (string) $this->username;
}
public function getRoles(): array
{
return $this->roles;
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
public function getPassword(): ?string
{
return $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
public function getPlainPassword(): string
{
return $this->plainPassword;
}
public function issetPlainPassword(): bool
{
if(isset ($this->plainPassword)){
return true;
};
return false;
}
public function setPlainPassword(string $plainPassword): void
{
$this->plainPassword = $plainPassword;
}
/**
* Returning a salt is only needed, if you are not using a modern
* hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
*
* @see UserInterface
*/
public function getSalt(): ?string
{
return null;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
$this->plainPassword = null;
}
public function isEnabled(): ?bool
{
return $this->enabled;
}
public function setEnabled(bool $enabled): self
{
$this->enabled = $enabled;
return $this;
}
public function getFirstName(): ?string
{
return $this->firstName;
}
public function setFirstName(string $firstName): self
{
$this->firstName = $firstName;
return $this;
}
public function getLastName(): ?string
{
return $this->lastName;
}
public function setLastName(string $lastName): self
{
$this->lastName = $lastName;
return $this;
}
public function getFullName(): ?string
{
return $this->firstName.' '.$this->lastName;
}
public function getAvatar(): ?string
{
return $this->avatar;
}
public function getAvatarUrl(): ?string
{
if (!$this->avatar) {
return null;
}
if (strpos($this->avatar, '/') !== false) {
return $this->avatar;
}
return sprintf('/uploads/avatars/%s', $this->avatar);
}
public function setAvatar(?string $avatar): self
{
$this->avatar = $avatar;
return $this;
}
/**
* @return Collection<int, Question>
*/
public function getQuestions(): Collection
{
return $this->questions;
}
public function addQuestion(Question $question): self
{
if (!$this->questions->contains($question)) {
$this->questions->add($question);
$question->setAskedBy($this);
}
return $this;
}
public function removeQuestion(Question $question): self
{
if ($this->questions->removeElement($question)) {
// set the owning side to null (unless already changed)
if ($question->getAskedBy() === $this) {
$question->setAskedBy(null);
}
}
return $this;
}
/**
* @return Collection<int, Answer>
*/
public function getAnswers(): Collection
{
return $this->answers;
}
public function addAnswer(Answer $answer): self
{
if (!$this->answers->contains($answer)) {
$this->answers->add($answer);
$answer->setAnsweredBy($this);
}
return $this;
}
public function removeAnswer(Answer $answer): self
{
if ($this->answers->removeElement($answer)) {
// set the owning side to null (unless already changed)
if ($answer->getAnsweredBy() === $this) {
$answer->setAnsweredBy(null);
}
}
return $this;
}
/**
* @return Collection<int, Order>
*/
public function getOrders(): Collection
{
return $this->orders;
}
public function addOrder(Order $order): self
{
if (!$this->orders->contains($order)) {
$this->orders->add($order);
$order->setVergunningMedewerker($this);
}
return $this;
}
public function removeOrder(Order $order): self
{
if ($this->orders->removeElement($order)) {
// set the owning side to null (unless already changed)
if ($order->getVergunningMedewerker() === $this) {
$order->setVergunningMedewerker(null);
}
}
return $this;
}
public function setUsername(string $username): self
{
$this->username = $username;
return $this;
}
/**
* @return Collection<int, Order>
*/
public function getOrderss(): Collection
{
return $this->orderss;
}
public function addOrderss(Order $orderss): self
{
if (!$this->orderss->contains($orderss)) {
$this->orderss->add($orderss);
$orderss->setOfferteMedewerker($this);
}
return $this;
}
public function removeOrderss(Order $orderss): self
{
if ($this->orderss->removeElement($orderss)) {
// set the owning side to null (unless already changed)
if ($orderss->getOfferteMedewerker() === $this) {
$orderss->setOfferteMedewerker(null);
}
}
return $this;
}
/**
* @return Collection<int, Order>
*/
public function getOrdersAfhalerContactmedewerker(): Collection
{
return $this->orders_afhaler_contactmedewerker;
}
public function addOrdersAfhalerContactmedewerker(Order $ordersAfhalerContactmedewerker): self
{
if (!$this->orders_afhaler_contactmedewerker->contains($ordersAfhalerContactmedewerker)) {
$this->orders_afhaler_contactmedewerker->add($ordersAfhalerContactmedewerker);
$ordersAfhalerContactmedewerker->setAfhalerContactmedewerker($this);
}
return $this;
}
public function removeOrdersAfhalerContactmedewerker(Order $ordersAfhalerContactmedewerker): self
{
if ($this->orders_afhaler_contactmedewerker->removeElement($ordersAfhalerContactmedewerker)) {
// set the owning side to null (unless already changed)
if ($ordersAfhalerContactmedewerker->getAfhalerContactmedewerker() === $this) {
$ordersAfhalerContactmedewerker->setAfhalerContactmedewerker(null);
}
}
return $this;
}
/**
* @return Collection<int, Reminder>
*/
public function getReminders(): Collection
{
return $this->reminders;
}
public function addReminder(Reminder $reminder): self
{
if (!$this->reminders->contains($reminder)) {
$this->reminders->add($reminder);
$reminder->setUser($this);
}
return $this;
}
public function removeReminder(Reminder $reminder): self
{
if ($this->reminders->removeElement($reminder)) {
// set the owning side to null (unless already changed)
if ($reminder->getUser() === $this) {
$reminder->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Groep>
*/
public function getGroepen(): Collection
{
return $this->groepen;
}
public function addGroepen(Groep $groepen): static
{
if (!$this->groepen->contains($groepen)) {
$this->groepen->add($groepen);
$groepen->addUser($this);
}
return $this;
}
public function removeGroepen(Groep $groepen): static
{
if ($this->groepen->removeElement($groepen)) {
$groepen->removeUser($this);
}
return $this;
}
/**
* @return Collection<int, Reminder>
*/
public function getCreatedReminders(): Collection
{
return $this->created_reminders;
}
public function addCreatedReminder(Reminder $createdReminder): static
{
if (!$this->created_reminders->contains($createdReminder)) {
$this->created_reminders->add($createdReminder);
$createdReminder->setIngevoerdDoor($this);
}
return $this;
}
public function removeCreatedReminder(Reminder $createdReminder): static
{
if ($this->created_reminders->removeElement($createdReminder)) {
// set the owning side to null (unless already changed)
if ($createdReminder->getIngevoerdDoor() === $this) {
$createdReminder->setIngevoerdDoor(null);
}
}
return $this;
}
}