<?php
namespace App\Entity;
use App\Entity\Dispatch\Dispatch;
use App\Entity\Documentation\CargoManifest;
use App\Entity\Documentation\Document;
use App\Entity\Documentation\ShippingCargoManifest;
use App\Entity\Documentation\MasterGuide;
use App\Entity\Documentation\ShippingPackingList;
use App\Entity\Expedient\Log;
use App\Entity\Quote\Quote;
use App\Repository\AppUserRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* @ORM\Entity(repositoryClass=AppUserRepository::class)
*/
class AppUser implements UserInterface, PasswordAuthenticatedUserInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=180, unique=true)
*/
private $username;
/**
* @ORM\Column(type="json")
*/
private $roles = [];
/**
* @var string The hashed password
* @ORM\Column(type="string")
*/
private $password;
/**
* @ORM\ManyToOne(targetEntity=CurrencyChange::class, inversedBy="users")
*/
private $currency;
/**
* @ORM\Column(type="string", length=1024)
*/
private $fullName;
/**
* @ORM\OneToMany(targetEntity=Log::class, mappedBy="generatedBy")
*/
private $logs;
/**
* @ORM\OneToMany(targetEntity=Dispatch::class, mappedBy="createdBy")
*/
private $dispatches;
/**
* @ORM\OneToMany(targetEntity=MasterGuide::class, mappedBy="generatedBy")
*/
private $masterGuides;
/**
* @ORM\OneToMany(targetEntity=CargoManifest::class, mappedBy="generatedBy")
*/
private $cargoManifests;
/**
* @ORM\OneToMany(targetEntity=Document::class, mappedBy="generatedBy")
*/
private $documents;
/**
* @ORM\OneToMany(targetEntity=ShippingCargoManifest::class, mappedBy="generatedBy")
*/
private $shippingCargoManifests;
/**
* @ORM\OneToMany(targetEntity=ShippingPackingList::class, mappedBy="generatedBy")
*/
private $shippingPackingLists;
/**
* @ORM\OneToMany(targetEntity=\App\Entity\Dispatch\Log::class, mappedBy="createdBy")
*/
private $dispatchLogs;
/**
* @ORM\OneToMany(targetEntity=Shipping::class, mappedBy="createdBy")
*/
private $shippings;
/**
* @ORM\OneToMany(targetEntity=Quote::class, mappedBy="createdBy")
*/
private $quotes;
/**
* @ORM\OneToMany(targetEntity=\App\Entity\Quote\Log::class, mappedBy="createdBy")
*/
private $quoteLogs;
public function __construct()
{
$this->logs = new ArrayCollection();
$this->dispatches = new ArrayCollection();
$this->masterGuides = new ArrayCollection();
$this->cargoManifests = new ArrayCollection();
$this->documents = new ArrayCollection();
$this->shippingCargoManifests = new ArrayCollection();
$this->shippingPackingLists = new ArrayCollection();
$this->dispatchLogs = new ArrayCollection();
$this->shippings = new ArrayCollection();
$this->quotes = new ArrayCollection();
$this->quoteLogs = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
/**
* @deprecated since Symfony 5.3, use getUserIdentifier instead
*/
public function getUsername(): string
{
return (string)$this->username;
}
public function setUsername(string $username): self
{
$this->username = $username;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return (string)$this->username;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_ADMIN';
return array_unique($roles);
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): string
{
return $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* 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 getCurrency(): ?CurrencyChange
{
return $this->currency;
}
public function setCurrency(?CurrencyChange $currency): self
{
$this->currency = $currency;
return $this;
}
public function getFullName(): ?string
{
return $this->fullName;
}
public function setFullName(string $fullName): self
{
$this->fullName = $fullName;
return $this;
}
/**
* @return Collection<int, Log>
*/
public function getLogs(): Collection
{
return $this->logs;
}
public function addLog(Log $log): self
{
if (!$this->logs->contains($log)) {
$this->logs[] = $log;
$log->setGeneratedBy($this);
}
return $this;
}
public function removeLog(Log $log): self
{
if ($this->logs->removeElement($log)) {
// set the owning side to null (unless already changed)
if ($log->getGeneratedBy() === $this) {
$log->setGeneratedBy(null);
}
}
return $this;
}
/**
* @return Collection<int, Dispatch>
*/
public function getDispatches(): Collection
{
return $this->dispatches;
}
public function addDispatch(Dispatch $dispatch): self
{
if (!$this->dispatches->contains($dispatch)) {
$this->dispatches[] = $dispatch;
$dispatch->setCreatedBy($this);
}
return $this;
}
public function removeDispatch(Dispatch $dispatch): self
{
if ($this->dispatches->removeElement($dispatch)) {
// set the owning side to null (unless already changed)
if ($dispatch->getCreatedBy() === $this) {
$dispatch->setCreatedBy(null);
}
}
return $this;
}
/**
* @return Collection<int, MasterGuide>
*/
public function getMasterGuides(): Collection
{
return $this->masterGuides;
}
public function addMasterGuide(MasterGuide $masterGuide): self
{
if (!$this->masterGuides->contains($masterGuide)) {
$this->masterGuides[] = $masterGuide;
$masterGuide->setGeneratedBy($this);
}
return $this;
}
public function removeMasterGuide(MasterGuide $masterGuide): self
{
if ($this->masterGuides->removeElement($masterGuide)) {
// set the owning side to null (unless already changed)
if ($masterGuide->getGeneratedBy() === $this) {
$masterGuide->setGeneratedBy(null);
}
}
return $this;
}
/**
* @return Collection<int, CargoManifest>
*/
public function getCargoManifests(): Collection
{
return $this->cargoManifests;
}
public function addCargoManifest(CargoManifest $cargoManifest): self
{
if (!$this->cargoManifests->contains($cargoManifest)) {
$this->cargoManifests[] = $cargoManifest;
$cargoManifest->setGeneratedBy($this);
}
return $this;
}
public function removeCargoManifest(CargoManifest $cargoManifest): self
{
if ($this->cargoManifests->removeElement($cargoManifest)) {
// set the owning side to null (unless already changed)
if ($cargoManifest->getGeneratedBy() === $this) {
$cargoManifest->setGeneratedBy(null);
}
}
return $this;
}
/**
* @return Collection<int, Document>
*/
public function getDocuments(): Collection
{
return $this->documents;
}
public function addDocument(Document $document): self
{
if (!$this->documents->contains($document)) {
$this->documents[] = $document;
$document->setGeneratedBy($this);
}
return $this;
}
public function removeDocument(Document $document): self
{
if ($this->documents->removeElement($document)) {
// set the owning side to null (unless already changed)
if ($document->getGeneratedBy() === $this) {
$document->setGeneratedBy(null);
}
}
return $this;
}
/**
* @return Collection<int, ShippingCargoManifest>
*/
public function getShippingCargoManifests(): Collection
{
return $this->shippingCargoManifests;
}
public function addShippingCargoManifest(ShippingCargoManifest $shippingCargoManifest): self
{
if (!$this->shippingCargoManifests->contains($shippingCargoManifest)) {
$this->shippingCargoManifests[] = $shippingCargoManifest;
$shippingCargoManifest->setGeneratedBy($this);
}
return $this;
}
public function removeShippingCargoManifest(ShippingCargoManifest $shippingCargoManifest): self
{
if ($this->shippingCargoManifests->removeElement($shippingCargoManifest)) {
// set the owning side to null (unless already changed)
if ($shippingCargoManifest->getGeneratedBy() === $this) {
$shippingCargoManifest->setGeneratedBy(null);
}
}
return $this;
}
/**
* @return Collection<int, ShippingPackingList>
*/
public function getShippingPackingLists(): Collection
{
return $this->shippingPackingLists;
}
public function addShippingPackingList(ShippingPackingList $shippingPackingList): self
{
if (!$this->shippingPackingLists->contains($shippingPackingList)) {
$this->shippingPackingLists[] = $shippingPackingList;
$shippingPackingList->setGeneratedBy($this);
}
return $this;
}
public function removeShippingPackingList(ShippingPackingList $shippingPackingList): self
{
if ($this->shippingPackingLists->removeElement($shippingPackingList)) {
// set the owning side to null (unless already changed)
if ($shippingPackingList->getGeneratedBy() === $this) {
$shippingPackingList->setGeneratedBy(null);
}
}
return $this;
}
public function __toString()
{
return $this->fullName;
}
/**
* @return Collection<int, \App\Entity\Dispatch\Log>
*/
public function getDispatchLogs(): Collection
{
return $this->dispatchLogs;
}
public function addDispatchLog(\App\Entity\Dispatch\Log $dispatchLog): self
{
if (!$this->dispatchLogs->contains($dispatchLog)) {
$this->dispatchLogs[] = $dispatchLog;
$dispatchLog->setCreatedBy($this);
}
return $this;
}
public function removeDispatchLog(\App\Entity\Dispatch\Log $dispatchLog): self
{
if ($this->dispatchLogs->removeElement($dispatchLog)) {
// set the owning side to null (unless already changed)
if ($dispatchLog->getCreatedBy() === $this) {
$dispatchLog->setCreatedBy(null);
}
}
return $this;
}
/**
* @return Collection<int, Shipping>
*/
public function getShippings(): Collection
{
return $this->shippings;
}
public function addShipping(Shipping $shipping): self
{
if (!$this->shippings->contains($shipping)) {
$this->shippings[] = $shipping;
$shipping->setCreatedBy($this);
}
return $this;
}
public function removeShipping(Shipping $shipping): self
{
if ($this->shippings->removeElement($shipping)) {
// set the owning side to null (unless already changed)
if ($shipping->getCreatedBy() === $this) {
$shipping->setCreatedBy(null);
}
}
return $this;
}
/**
* @return Collection<int, Quote>
*/
public function getQuotes(): Collection
{
return $this->quotes;
}
public function addQuote(Quote $quote): self
{
if (!$this->quotes->contains($quote)) {
$this->quotes[] = $quote;
$quote->setCreatedBy($this);
}
return $this;
}
public function removeQuote(Quote $quote): self
{
if ($this->quotes->removeElement($quote)) {
// set the owning side to null (unless already changed)
if ($quote->getCreatedBy() === $this) {
$quote->setCreatedBy(null);
}
}
return $this;
}
/**
* @return Collection<int, \App\Entity\Quote\Log>
*/
public function getQuoteLogs(): Collection
{
return $this->quoteLogs;
}
public function addQuoteLog(\App\Entity\Quote\Log $quoteLog): self
{
if (!$this->quoteLogs->contains($quoteLog)) {
$this->quoteLogs[] = $quoteLog;
$quoteLog->setCreatedBy($this);
}
return $this;
}
public function removeQuoteLog(\App\Entity\Quote\Log $quoteLog): self
{
if ($this->quoteLogs->removeElement($quoteLog)) {
// set the owning side to null (unless already changed)
if ($quoteLog->getCreatedBy() === $this) {
$quoteLog->setCreatedBy(null);
}
}
return $this;
}
}