src/Entity/AppUser.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Dispatch\Dispatch;
  4. use App\Entity\Documentation\CargoManifest;
  5. use App\Entity\Documentation\Document;
  6. use App\Entity\Documentation\ShippingCargoManifest;
  7. use App\Entity\Documentation\MasterGuide;
  8. use App\Entity\Documentation\ShippingPackingList;
  9. use App\Entity\Expedient\Log;
  10. use App\Entity\Quote\Quote;
  11. use App\Repository\AppUserRepository;
  12. use Doctrine\Common\Collections\ArrayCollection;
  13. use Doctrine\Common\Collections\Collection;
  14. use Doctrine\ORM\Mapping as ORM;
  15. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  16. use Symfony\Component\Security\Core\User\UserInterface;
  17. /**
  18.  * @ORM\Entity(repositoryClass=AppUserRepository::class)
  19.  */
  20. class AppUser implements UserInterfacePasswordAuthenticatedUserInterface
  21. {
  22.     /**
  23.      * @ORM\Id
  24.      * @ORM\GeneratedValue
  25.      * @ORM\Column(type="integer")
  26.      */
  27.     private $id;
  28.     /**
  29.      * @ORM\Column(type="string", length=180, unique=true)
  30.      */
  31.     private $username;
  32.     /**
  33.      * @ORM\Column(type="json")
  34.      */
  35.     private $roles = [];
  36.     /**
  37.      * @var string The hashed password
  38.      * @ORM\Column(type="string")
  39.      */
  40.     private $password;
  41.     /**
  42.      * @ORM\ManyToOne(targetEntity=CurrencyChange::class, inversedBy="users")
  43.      */
  44.     private $currency;
  45.     /**
  46.      * @ORM\Column(type="string", length=1024)
  47.      */
  48.     private $fullName;
  49.     /**
  50.      * @ORM\OneToMany(targetEntity=Log::class, mappedBy="generatedBy")
  51.      */
  52.     private $logs;
  53.     /**
  54.      * @ORM\OneToMany(targetEntity=Dispatch::class, mappedBy="createdBy")
  55.      */
  56.     private $dispatches;
  57.     /**
  58.      * @ORM\OneToMany(targetEntity=MasterGuide::class, mappedBy="generatedBy")
  59.      */
  60.     private $masterGuides;
  61.     /**
  62.      * @ORM\OneToMany(targetEntity=CargoManifest::class, mappedBy="generatedBy")
  63.      */
  64.     private $cargoManifests;
  65.     /**
  66.      * @ORM\OneToMany(targetEntity=Document::class, mappedBy="generatedBy")
  67.      */
  68.     private $documents;
  69.     /**
  70.      * @ORM\OneToMany(targetEntity=ShippingCargoManifest::class, mappedBy="generatedBy")
  71.      */
  72.     private $shippingCargoManifests;
  73.     /**
  74.      * @ORM\OneToMany(targetEntity=ShippingPackingList::class, mappedBy="generatedBy")
  75.      */
  76.     private $shippingPackingLists;
  77.     /**
  78.      * @ORM\OneToMany(targetEntity=\App\Entity\Dispatch\Log::class, mappedBy="createdBy")
  79.      */
  80.     private $dispatchLogs;
  81.     /**
  82.      * @ORM\OneToMany(targetEntity=Shipping::class, mappedBy="createdBy")
  83.      */
  84.     private $shippings;
  85.     /**
  86.      * @ORM\OneToMany(targetEntity=Quote::class, mappedBy="createdBy")
  87.      */
  88.     private $quotes;
  89.     /**
  90.      * @ORM\OneToMany(targetEntity=\App\Entity\Quote\Log::class, mappedBy="createdBy")
  91.      */
  92.     private $quoteLogs;
  93.     public function __construct()
  94.     {
  95.         $this->logs = new ArrayCollection();
  96.         $this->dispatches = new ArrayCollection();
  97.         $this->masterGuides = new ArrayCollection();
  98.         $this->cargoManifests = new ArrayCollection();
  99.         $this->documents = new ArrayCollection();
  100.         $this->shippingCargoManifests = new ArrayCollection();
  101.         $this->shippingPackingLists = new ArrayCollection();
  102.         $this->dispatchLogs = new ArrayCollection();
  103.         $this->shippings = new ArrayCollection();
  104.         $this->quotes = new ArrayCollection();
  105.         $this->quoteLogs = new ArrayCollection();
  106.     }
  107.     public function getId(): ?int
  108.     {
  109.         return $this->id;
  110.     }
  111.     /**
  112.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  113.      */
  114.     public function getUsername(): string
  115.     {
  116.         return (string)$this->username;
  117.     }
  118.     public function setUsername(string $username): self
  119.     {
  120.         $this->username $username;
  121.         return $this;
  122.     }
  123.     /**
  124.      * A visual identifier that represents this user.
  125.      *
  126.      * @see UserInterface
  127.      */
  128.     public function getUserIdentifier(): string
  129.     {
  130.         return (string)$this->username;
  131.     }
  132.     /**
  133.      * @see UserInterface
  134.      */
  135.     public function getRoles(): array
  136.     {
  137.         $roles $this->roles;
  138.         // guarantee every user at least has ROLE_USER
  139.         $roles[] = 'ROLE_ADMIN';
  140.         return array_unique($roles);
  141.     }
  142.     public function setRoles(array $roles): self
  143.     {
  144.         $this->roles $roles;
  145.         return $this;
  146.     }
  147.     /**
  148.      * @see PasswordAuthenticatedUserInterface
  149.      */
  150.     public function getPassword(): string
  151.     {
  152.         return $this->password;
  153.     }
  154.     public function setPassword(string $password): self
  155.     {
  156.         $this->password $password;
  157.         return $this;
  158.     }
  159.     /**
  160.      * Returning a salt is only needed, if you are not using a modern
  161.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  162.      *
  163.      * @see UserInterface
  164.      */
  165.     public function getSalt(): ?string
  166.     {
  167.         return null;
  168.     }
  169.     /**
  170.      * @see UserInterface
  171.      */
  172.     public function eraseCredentials()
  173.     {
  174.         // If you store any temporary, sensitive data on the user, clear it here
  175.         // $this->plainPassword = null;
  176.     }
  177.     public function getCurrency(): ?CurrencyChange
  178.     {
  179.         return $this->currency;
  180.     }
  181.     public function setCurrency(?CurrencyChange $currency): self
  182.     {
  183.         $this->currency $currency;
  184.         return $this;
  185.     }
  186.     public function getFullName(): ?string
  187.     {
  188.         return $this->fullName;
  189.     }
  190.     public function setFullName(string $fullName): self
  191.     {
  192.         $this->fullName $fullName;
  193.         return $this;
  194.     }
  195.     /**
  196.      * @return Collection<int, Log>
  197.      */
  198.     public function getLogs(): Collection
  199.     {
  200.         return $this->logs;
  201.     }
  202.     public function addLog(Log $log): self
  203.     {
  204.         if (!$this->logs->contains($log)) {
  205.             $this->logs[] = $log;
  206.             $log->setGeneratedBy($this);
  207.         }
  208.         return $this;
  209.     }
  210.     public function removeLog(Log $log): self
  211.     {
  212.         if ($this->logs->removeElement($log)) {
  213.             // set the owning side to null (unless already changed)
  214.             if ($log->getGeneratedBy() === $this) {
  215.                 $log->setGeneratedBy(null);
  216.             }
  217.         }
  218.         return $this;
  219.     }
  220.     /**
  221.      * @return Collection<int, Dispatch>
  222.      */
  223.     public function getDispatches(): Collection
  224.     {
  225.         return $this->dispatches;
  226.     }
  227.     public function addDispatch(Dispatch $dispatch): self
  228.     {
  229.         if (!$this->dispatches->contains($dispatch)) {
  230.             $this->dispatches[] = $dispatch;
  231.             $dispatch->setCreatedBy($this);
  232.         }
  233.         return $this;
  234.     }
  235.     public function removeDispatch(Dispatch $dispatch): self
  236.     {
  237.         if ($this->dispatches->removeElement($dispatch)) {
  238.             // set the owning side to null (unless already changed)
  239.             if ($dispatch->getCreatedBy() === $this) {
  240.                 $dispatch->setCreatedBy(null);
  241.             }
  242.         }
  243.         return $this;
  244.     }
  245.     /**
  246.      * @return Collection<int, MasterGuide>
  247.      */
  248.     public function getMasterGuides(): Collection
  249.     {
  250.         return $this->masterGuides;
  251.     }
  252.     public function addMasterGuide(MasterGuide $masterGuide): self
  253.     {
  254.         if (!$this->masterGuides->contains($masterGuide)) {
  255.             $this->masterGuides[] = $masterGuide;
  256.             $masterGuide->setGeneratedBy($this);
  257.         }
  258.         return $this;
  259.     }
  260.     public function removeMasterGuide(MasterGuide $masterGuide): self
  261.     {
  262.         if ($this->masterGuides->removeElement($masterGuide)) {
  263.             // set the owning side to null (unless already changed)
  264.             if ($masterGuide->getGeneratedBy() === $this) {
  265.                 $masterGuide->setGeneratedBy(null);
  266.             }
  267.         }
  268.         return $this;
  269.     }
  270.     /**
  271.      * @return Collection<int, CargoManifest>
  272.      */
  273.     public function getCargoManifests(): Collection
  274.     {
  275.         return $this->cargoManifests;
  276.     }
  277.     public function addCargoManifest(CargoManifest $cargoManifest): self
  278.     {
  279.         if (!$this->cargoManifests->contains($cargoManifest)) {
  280.             $this->cargoManifests[] = $cargoManifest;
  281.             $cargoManifest->setGeneratedBy($this);
  282.         }
  283.         return $this;
  284.     }
  285.     public function removeCargoManifest(CargoManifest $cargoManifest): self
  286.     {
  287.         if ($this->cargoManifests->removeElement($cargoManifest)) {
  288.             // set the owning side to null (unless already changed)
  289.             if ($cargoManifest->getGeneratedBy() === $this) {
  290.                 $cargoManifest->setGeneratedBy(null);
  291.             }
  292.         }
  293.         return $this;
  294.     }
  295.     /**
  296.      * @return Collection<int, Document>
  297.      */
  298.     public function getDocuments(): Collection
  299.     {
  300.         return $this->documents;
  301.     }
  302.     public function addDocument(Document $document): self
  303.     {
  304.         if (!$this->documents->contains($document)) {
  305.             $this->documents[] = $document;
  306.             $document->setGeneratedBy($this);
  307.         }
  308.         return $this;
  309.     }
  310.     public function removeDocument(Document $document): self
  311.     {
  312.         if ($this->documents->removeElement($document)) {
  313.             // set the owning side to null (unless already changed)
  314.             if ($document->getGeneratedBy() === $this) {
  315.                 $document->setGeneratedBy(null);
  316.             }
  317.         }
  318.         return $this;
  319.     }
  320.     /**
  321.      * @return Collection<int, ShippingCargoManifest>
  322.      */
  323.     public function getShippingCargoManifests(): Collection
  324.     {
  325.         return $this->shippingCargoManifests;
  326.     }
  327.     public function addShippingCargoManifest(ShippingCargoManifest $shippingCargoManifest): self
  328.     {
  329.         if (!$this->shippingCargoManifests->contains($shippingCargoManifest)) {
  330.             $this->shippingCargoManifests[] = $shippingCargoManifest;
  331.             $shippingCargoManifest->setGeneratedBy($this);
  332.         }
  333.         return $this;
  334.     }
  335.     public function removeShippingCargoManifest(ShippingCargoManifest $shippingCargoManifest): self
  336.     {
  337.         if ($this->shippingCargoManifests->removeElement($shippingCargoManifest)) {
  338.             // set the owning side to null (unless already changed)
  339.             if ($shippingCargoManifest->getGeneratedBy() === $this) {
  340.                 $shippingCargoManifest->setGeneratedBy(null);
  341.             }
  342.         }
  343.         return $this;
  344.     }
  345.     /**
  346.      * @return Collection<int, ShippingPackingList>
  347.      */
  348.     public function getShippingPackingLists(): Collection
  349.     {
  350.         return $this->shippingPackingLists;
  351.     }
  352.     public function addShippingPackingList(ShippingPackingList $shippingPackingList): self
  353.     {
  354.         if (!$this->shippingPackingLists->contains($shippingPackingList)) {
  355.             $this->shippingPackingLists[] = $shippingPackingList;
  356.             $shippingPackingList->setGeneratedBy($this);
  357.         }
  358.         return $this;
  359.     }
  360.     public function removeShippingPackingList(ShippingPackingList $shippingPackingList): self
  361.     {
  362.         if ($this->shippingPackingLists->removeElement($shippingPackingList)) {
  363.             // set the owning side to null (unless already changed)
  364.             if ($shippingPackingList->getGeneratedBy() === $this) {
  365.                 $shippingPackingList->setGeneratedBy(null);
  366.             }
  367.         }
  368.         return $this;
  369.     }
  370.     public function __toString()
  371.     {
  372.         return $this->fullName;
  373.     }
  374.     /**
  375.      * @return Collection<int, \App\Entity\Dispatch\Log>
  376.      */
  377.     public function getDispatchLogs(): Collection
  378.     {
  379.         return $this->dispatchLogs;
  380.     }
  381.     public function addDispatchLog(\App\Entity\Dispatch\Log $dispatchLog): self
  382.     {
  383.         if (!$this->dispatchLogs->contains($dispatchLog)) {
  384.             $this->dispatchLogs[] = $dispatchLog;
  385.             $dispatchLog->setCreatedBy($this);
  386.         }
  387.         return $this;
  388.     }
  389.     public function removeDispatchLog(\App\Entity\Dispatch\Log $dispatchLog): self
  390.     {
  391.         if ($this->dispatchLogs->removeElement($dispatchLog)) {
  392.             // set the owning side to null (unless already changed)
  393.             if ($dispatchLog->getCreatedBy() === $this) {
  394.                 $dispatchLog->setCreatedBy(null);
  395.             }
  396.         }
  397.         return $this;
  398.     }
  399.     /**
  400.      * @return Collection<int, Shipping>
  401.      */
  402.     public function getShippings(): Collection
  403.     {
  404.         return $this->shippings;
  405.     }
  406.     public function addShipping(Shipping $shipping): self
  407.     {
  408.         if (!$this->shippings->contains($shipping)) {
  409.             $this->shippings[] = $shipping;
  410.             $shipping->setCreatedBy($this);
  411.         }
  412.         return $this;
  413.     }
  414.     public function removeShipping(Shipping $shipping): self
  415.     {
  416.         if ($this->shippings->removeElement($shipping)) {
  417.             // set the owning side to null (unless already changed)
  418.             if ($shipping->getCreatedBy() === $this) {
  419.                 $shipping->setCreatedBy(null);
  420.             }
  421.         }
  422.         return $this;
  423.     }
  424.     /**
  425.      * @return Collection<int, Quote>
  426.      */
  427.     public function getQuotes(): Collection
  428.     {
  429.         return $this->quotes;
  430.     }
  431.     public function addQuote(Quote $quote): self
  432.     {
  433.         if (!$this->quotes->contains($quote)) {
  434.             $this->quotes[] = $quote;
  435.             $quote->setCreatedBy($this);
  436.         }
  437.         return $this;
  438.     }
  439.     public function removeQuote(Quote $quote): self
  440.     {
  441.         if ($this->quotes->removeElement($quote)) {
  442.             // set the owning side to null (unless already changed)
  443.             if ($quote->getCreatedBy() === $this) {
  444.                 $quote->setCreatedBy(null);
  445.             }
  446.         }
  447.         return $this;
  448.     }
  449.     /**
  450.      * @return Collection<int, \App\Entity\Quote\Log>
  451.      */
  452.     public function getQuoteLogs(): Collection
  453.     {
  454.         return $this->quoteLogs;
  455.     }
  456.     public function addQuoteLog(\App\Entity\Quote\Log $quoteLog): self
  457.     {
  458.         if (!$this->quoteLogs->contains($quoteLog)) {
  459.             $this->quoteLogs[] = $quoteLog;
  460.             $quoteLog->setCreatedBy($this);
  461.         }
  462.         return $this;
  463.     }
  464.     public function removeQuoteLog(\App\Entity\Quote\Log $quoteLog): self
  465.     {
  466.         if ($this->quoteLogs->removeElement($quoteLog)) {
  467.             // set the owning side to null (unless already changed)
  468.             if ($quoteLog->getCreatedBy() === $this) {
  469.                 $quoteLog->setCreatedBy(null);
  470.             }
  471.         }
  472.         return $this;
  473.     }
  474. }