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\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  8. use Symfony\Component\Security\Core\User\UserInterface;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. /**
  11.  * @ORM\Entity(repositoryClass=UserRepository::class)
  12.  */
  13. class User implements UserInterfacePasswordAuthenticatedUserInterface
  14. {
  15.     /**
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue
  18.      * @ORM\Column(type="integer")
  19.      */
  20.     private $id;
  21.     /**
  22.      * @ORM\Column(type="string", length=180, unique=true)
  23.      */
  24.     private $email;
  25.     /**
  26.      * @ORM\Column(type="json")
  27.      */
  28.     private $roles = [];
  29.     /**
  30.      * @var string The hashed password
  31.      * @ORM\Column(type="string")     */
  32.     private $password;
  33.     /**
  34.      * @ORM\Column(type="string", length=255, nullable=true)
  35.      */
  36.     private $firstname;
  37.     /**
  38.      * @ORM\Column(type="string", length=255, nullable=true)
  39.      */
  40.     private $lastname;
  41.     /**
  42.      * @ORM\Column(type="string", length=255, nullable=true)
  43.      */
  44.     private $avatar;
  45.     /**
  46.      * @ORM\Column(type="string", length=255, nullable=true)
  47.      */
  48.     private $avtatarFilename;
  49.     /**
  50.      * @ORM\OneToMany(targetEntity=Employee::class, mappedBy="owner")
  51.      */
  52.     private $employees;
  53.     /**
  54.      * @ORM\OneToMany(targetEntity=EstimatedExpenses::class, mappedBy="owner")
  55.      */
  56.     private $estimated_expenses;
  57.     /**
  58.      * @ORM\OneToMany(targetEntity=Parameters::class, mappedBy="owner")
  59.      */
  60.     private $parameters;
  61.     /**
  62.      * @ORM\OneToMany(targetEntity=Archives::class, mappedBy="owner")
  63.      */
  64.     private $archives;
  65.     /**
  66.      * @ORM\OneToMany(targetEntity=AccountingPlan::class, mappedBy="owner")
  67.      */
  68.     private $accountingPlans;
  69.     /**
  70.      * @ORM\Column(type="string", length=100, nullable=true)
  71.      */
  72.     private $resetToken;
  73.     /**
  74.      * @ORM\OneToMany(targetEntity=Quote::class, mappedBy="owner")
  75.      */
  76.     private $quotes;
  77.     /**
  78.      * @ORM\OneToOne(targetEntity=Company::class, mappedBy="owner", cascade={"persist", "remove"})
  79.      */
  80.     private $company;
  81.     /**
  82.      * @ORM\OneToMany(targetEntity=Product::class, mappedBy="owner")
  83.      */
  84.     private $products;
  85.     /**
  86.      * @ORM\OneToMany(targetEntity=Client::class, mappedBy="owner")
  87.      */
  88.     private $clients;
  89.     
  90.     /**
  91.      * @ORM\Column(type="boolean")
  92.      */
  93.     private $isVerified false;
  94.     public function __construct()
  95.     {
  96.         $this->employees = new ArrayCollection();
  97.         $this->estimated_expenses = new ArrayCollection();
  98.         $this->parameters = new ArrayCollection();
  99.         $this->archives = new ArrayCollection();
  100.         $this->accountingPlans = new ArrayCollection();
  101.         $this->quotes = new ArrayCollection();
  102.         $this->products = new ArrayCollection();
  103.         $this->clients = new ArrayCollection();
  104.     }
  105.     public function getId(): ?int
  106.     {
  107.         return $this->id;
  108.     }
  109.     public function getEmail(): ?string
  110.     {
  111.         return $this->email;
  112.     }
  113.     public function setEmail(string $email): self
  114.     {
  115.         $this->email $email;
  116.         return $this;
  117.     }
  118.     /**
  119.      * A visual identifier that represents this user.
  120.      *
  121.      * @see UserInterface
  122.      */
  123.     public function getUserIdentifier(): string
  124.     {
  125.         return (string) $this->email;
  126.     }
  127.     /**
  128.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  129.      */
  130.     public function getUsername(): string
  131.     {
  132.         return (string) $this->email;
  133.     }
  134.     /**
  135.      * @see UserInterface
  136.      */
  137.     public function getRoles(): array
  138.     {
  139.         $roles $this->roles;
  140.         // guarantee every user at least has ROLE_USER
  141.         $roles[] = 'ROLE_USER';
  142.         return array_unique($roles);
  143.     }
  144.     public function setRoles(array $roles): self
  145.     {
  146.         $this->roles $roles;
  147.         return $this;
  148.     }
  149.     /**
  150.      * @see PasswordAuthenticatedUserInterface
  151.      */
  152.     public function getPassword(): string
  153.     {
  154.         return $this->password;
  155.     }
  156.     public function setPassword(string $password): self
  157.     {
  158.         $this->password $password;
  159.         return $this;
  160.     }
  161.     /**
  162.      * Returning a salt is only needed, if you are not using a modern
  163.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  164.      *
  165.      * @see UserInterface
  166.      */
  167.     public function getSalt(): ?string
  168.     {
  169.         return null;
  170.     }
  171.     /**
  172.      * @see UserInterface
  173.      */
  174.     public function eraseCredentials()
  175.     {
  176.         // If you store any temporary, sensitive data on the user, clear it here
  177.         // $this->plainPassword = null;
  178.     }
  179.     public function getFirstname(): ?string
  180.     {
  181.         return $this->firstname;
  182.     }
  183.     public function setFirstname(?string $firstname): self
  184.     {
  185.         $this->firstname $firstname;
  186.         return $this;
  187.     }
  188.     public function getLastname(): ?string
  189.     {
  190.         return $this->lastname;
  191.     }
  192.     public function setLastname(?string $lastname): self
  193.     {
  194.         $this->lastname $lastname;
  195.         return $this;
  196.     }
  197.     public function getAvatar(): ?string
  198.     {
  199.         return $this->avatar;
  200.     }
  201.     public function setAvatar(?string $avatar): self
  202.     {
  203.         $this->avatar $avatar;
  204.         return $this;
  205.     }
  206.     public function getAvtatarFilename(): ?string
  207.     {
  208.         return $this->avtatarFilename;
  209.     }
  210.     public function setAvtatarFilename(?string $avtatarFilename): self
  211.     {
  212.         $this->avtatarFilename $avtatarFilename;
  213.         return $this;
  214.     }
  215.     /**
  216.      * @return Collection<int, Employee>
  217.      */
  218.     public function getEmployees(): Collection
  219.     {
  220.         return $this->employees;
  221.     }
  222.     public function addEmployee(Employee $employee): self
  223.     {
  224.         if (!$this->employees->contains($employee)) {
  225.             $this->employees[] = $employee;
  226.             $employee->setOwner($this);
  227.         }
  228.         return $this;
  229.     }
  230.     public function removeEmployee(Employee $employee): self
  231.     {
  232.         if ($this->employees->removeElement($employee)) {
  233.             // set the owning side to null (unless already changed)
  234.             if ($employee->getOwner() === $this) {
  235.                 $employee->setOwner(null);
  236.             }
  237.         }
  238.         return $this;
  239.     }
  240.     /**
  241.      * @return Collection<int, EstimatedExpenses>
  242.      */
  243.     public function getEstimatedExpenses(): Collection
  244.     {
  245.         return $this->estimated_expenses;
  246.     }
  247.     public function addEstimatedExpense(EstimatedExpenses $estimatedExpense): self
  248.     {
  249.         if (!$this->estimated_expenses->contains($estimatedExpense)) {
  250.             $this->estimated_expenses[] = $estimatedExpense;
  251.             $estimatedExpense->setOwner($this);
  252.         }
  253.         return $this;
  254.     }
  255.     public function removeEstimatedExpense(EstimatedExpenses $estimatedExpense): self
  256.     {
  257.         if ($this->estimated_expenses->removeElement($estimatedExpense)) {
  258.             // set the owning side to null (unless already changed)
  259.             if ($estimatedExpense->getOwner() === $this) {
  260.                 $estimatedExpense->setOwner(null);
  261.             }
  262.         }
  263.         return $this;
  264.     }
  265.     /**
  266.      * @return Collection<int, Parameters>
  267.      */
  268.     public function getParameters(): Collection
  269.     {
  270.         return $this->parameters;
  271.     }
  272.     public function addParameter(Parameters $parameter): self
  273.     {
  274.         if (!$this->parameters->contains($parameter)) {
  275.             $this->parameters[] = $parameter;
  276.             $parameter->setOwner($this);
  277.         }
  278.         return $this;
  279.     }
  280.     public function removeParameter(Parameters $parameter): self
  281.     {
  282.         if ($this->parameters->removeElement($parameter)) {
  283.             // set the owning side to null (unless already changed)
  284.             if ($parameter->getOwner() === $this) {
  285.                 $parameter->setOwner(null);
  286.             }
  287.         }
  288.         return $this;
  289.     }
  290.     /**
  291.      * @return Collection<int, Archives>
  292.      */
  293.     public function getArchives(): Collection
  294.     {
  295.         return $this->archives;
  296.     }
  297.     public function addArchive(Archives $archive): self
  298.     {
  299.         if (!$this->archives->contains($archive)) {
  300.             $this->archives[] = $archive;
  301.             $archive->setOwner($this);
  302.         }
  303.         return $this;
  304.     }
  305.     public function removeArchive(Archives $archive): self
  306.     {
  307.         if ($this->archives->removeElement($archive)) {
  308.             // set the owning side to null (unless already changed)
  309.             if ($archive->getOwner() === $this) {
  310.                 $archive->setOwner(null);
  311.             }
  312.         }
  313.         return $this;
  314.     }
  315.     /**
  316.      * @return Collection<int, AccountingPlan>
  317.      */
  318.     public function getAccountingPlans(): Collection
  319.     {
  320.         return $this->accountingPlans;
  321.     }
  322.     public function addAccountingPlan(AccountingPlan $accountingPlan): self
  323.     {
  324.         if (!$this->accountingPlans->contains($accountingPlan)) {
  325.             $this->accountingPlans[] = $accountingPlan;
  326.             $accountingPlan->setOwner($this);
  327.         }
  328.         return $this;
  329.     }
  330.     public function removeAccountingPlan(AccountingPlan $accountingPlan): self
  331.     {
  332.         if ($this->accountingPlans->removeElement($accountingPlan)) {
  333.             // set the owning side to null (unless already changed)
  334.             if ($accountingPlan->getOwner() === $this) {
  335.                 $accountingPlan->setOwner(null);
  336.             }
  337.         }
  338.         return $this;
  339.     }
  340.     public function getResetToken(): ?string
  341.     {
  342.         return $this->resetToken;
  343.     }
  344.     public function setResetToken(?string $resetToken): self
  345.     {
  346.         $this->resetToken $resetToken;
  347.         return $this;
  348.     }
  349.     /**
  350.      * @return Collection<int, Quote>
  351.      */
  352.     public function getQuotes(): Collection
  353.     {
  354.         return $this->quotes;
  355.     }
  356.     public function addQuote(Quote $quote): self
  357.     {
  358.         if (!$this->quotes->contains($quote)) {
  359.             $this->quotes[] = $quote;
  360.             $quote->setOwner($this);
  361.         }
  362.         return $this;
  363.     }
  364.     public function removeQuote(Quote $quote): self
  365.     {
  366.         if ($this->quotes->removeElement($quote)) {
  367.             // set the owning side to null (unless already changed)
  368.             if ($quote->getOwner() === $this) {
  369.                 $quote->setOwner(null);
  370.             }
  371.         }
  372.         return $this;
  373.     }
  374.     public function getCompany(): ?Company
  375.     {
  376.         return $this->company;
  377.     }
  378.     public function setCompany(?Company $company): self
  379.     {
  380.         // unset the owning side of the relation if necessary
  381.         if ($company === null && $this->company !== null) {
  382.             $this->company->setOwner(null);
  383.         }
  384.         // set the owning side of the relation if necessary
  385.         if ($company !== null && $company->getOwner() !== $this) {
  386.             $company->setOwner($this);
  387.         }
  388.         $this->company $company;
  389.         return $this;
  390.     }
  391.     /**
  392.      * @return Collection<int, Product>
  393.      */
  394.     public function getProducts(): Collection
  395.     {
  396.         return $this->products;
  397.     }
  398.     public function addProduct(Product $product): self
  399.     {
  400.         if (!$this->products->contains($product)) {
  401.             $this->products[] = $product;
  402.             $product->setOwner($this);
  403.         }
  404.         return $this;
  405.     }
  406.     public function removeProduct(Product $product): self
  407.     {
  408.         if ($this->products->removeElement($product)) {
  409.             // set the owning side to null (unless already changed)
  410.             if ($product->getOwner() === $this) {
  411.                 $product->setOwner(null);
  412.             }
  413.         }
  414.         return $this;
  415.     }
  416.     /**
  417.      * @return Collection<int, Client>
  418.      */
  419.     public function getClients(): Collection
  420.     {
  421.         return $this->clients;
  422.     }
  423.     public function addClient(Client $client): self
  424.     {
  425.         if (!$this->clients->contains($client)) {
  426.             $this->clients[] = $client;
  427.             $client->setOwner($this);
  428.         }
  429.         return $this;
  430.     }
  431.     public function removeClient(Client $client): self
  432.     {
  433.         if ($this->clients->removeElement($client)) {
  434.             // set the owning side to null (unless already changed)
  435.             if ($client->getOwner() === $this) {
  436.                 $client->setOwner(null);
  437.             }
  438.         }
  439.         return $this;
  440.     }
  441.     
  442.     public function isIsVerified(): ?bool
  443.     {
  444.         return $this->isVerified;
  445.     }
  446.     public function setIsVerified(bool $isVerified): self
  447.     {
  448.         $this->isVerified $isVerified;
  449.         return $this;
  450.     }
  451. }