src/Entity/User.php line 64

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use ApiPlatform\Metadata\ApiFilter;
  6. use ApiPlatform\Metadata\ApiProperty;
  7. use ApiPlatform\Metadata\ApiResource;
  8. use ApiPlatform\Metadata\Delete;
  9. use ApiPlatform\Metadata\Get;
  10. use ApiPlatform\Metadata\GetCollection;
  11. use ApiPlatform\Metadata\Patch;
  12. use ApiPlatform\Metadata\Post;
  13. use ApiPlatform\Metadata\Put;
  14. use Doctrine\ORM\Mapping as ORM;
  15. use App\Repository\UserRepository;
  16. use App\State\UserPasswordHasher;
  17. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  18. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  19. use Symfony\Component\Security\Core\User\UserInterface;
  20. use Symfony\Component\Serializer\Annotation\Groups;
  21. use Symfony\Component\Validator\Constraints as Assert;
  22. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  23. use App\Controller\UserController;
  24. use App\Filter\CustomOrFilter// Змініть імпорт на правильний
  25. // use ApiPlatform\Core\Metadata\Reswource\DeprecationMetadata;
  26. #[ORM\Table(name'users')]
  27. #[ApiResource(
  28.     operations: [
  29.         new GetCollection(),
  30.         new Post(processorUserPasswordHasher::class, validationContext: ['groups' => ['Default''user:create']]),
  31.         new Get(),
  32.         new Put(processorUserPasswordHasher::class),
  33.         new Patch(processorUserPasswordHasher::class),
  34.         new Post(
  35.             name'me'
  36.             uriTemplate'/users/me'
  37.             controllerUserController::class
  38.         )
  39.     ],
  40.     normalizationContext: ['groups' => ['user:read']],
  41.     denormalizationContext: ['groups' => ['user:create''user:update']],
  42. )]
  43. #[ORM\Entity(repositoryClassUserRepository::class)]
  44. #[UniqueEntity(fields: ['username'], message'There is already an account with this username')]
  45. #[ApiFilter(CustomOrFilter::class,properties: [
  46.     'username' => 'ipartial'
  47.     'firstName' => 'ipartial'
  48.     'lastName' => 'ipartial',
  49.     'codeUser' => 'exact',
  50.     'codeManager' => 'exact',
  51. ])]
  52. #[ApiFilter(SearchFilter::class, properties: [
  53.     'accounts.manager.id' => 'exact',
  54. ])]
  55. class User implements UserInterfacePasswordAuthenticatedUserInterface
  56. {
  57.     #[ORM\Id]
  58.     #[ORM\GeneratedValue]
  59.     #[ORM\Column]
  60.     #[Groups(['user:read''read''account:read''order:read''order_product:read''pre_order_product:read''pre_order:read''load_invoice:read''load_invocie:read''product_storage_balance:read''product:read'])]
  61.     private ?int $id null;
  62.     #[ORM\Column(length180uniquetrue)]
  63.     #[Groups(['user:read''user:create''user:update''read''account:read'])]
  64.     private ?string $username null;
  65.     #[Groups(['user:read''user:update'])]
  66.     #[ORM\Column]
  67.     private array $roles = [];
  68.     /**
  69.      * @var string The hashed password
  70.      */
  71.     #[ORM\Column]
  72.     private ?string $password null;
  73.     #[Assert\NotBlank(groups: ['user:create'])]
  74.     #[Groups(['user:create''user:update'])]
  75.     private ?string $plainPassword null;
  76.     #[ORM\ManyToOne(targetEntityself::class, inversedBy'firstName')]
  77.     private ?self $manager null;
  78.     #[Groups(['user:read''user:create''user:update''read''account:read''account:write''order:read''order_product:read''pre_order_product:read''pre_order:read''load_invoice:read''load_invocie:read''product_storage_balance:read''product:read'])]
  79.     #[ORM\Column(length255nullabletrue)]
  80.     private ?string $firstName  null;
  81.     #[Groups(['user:read''user:create''user:update''read''account:read''account:write''order:read''order_product:read''pre_order_product:read''pre_order:read''load_invoice:read''load_invocie:read''product_storage_balance:read''product:read'])]
  82.     #[ORM\Column(length255nullabletrue)]
  83.     private ?string $lastName null;
  84.     #[Groups(['user:read''user:create''user:update''account:read'])]
  85.     #[ORM\Column(length100nullabletrue)]
  86.     private ?string $phone null;
  87.     #[Groups(['user:read''user:create''user:update'])]
  88.     #[ORM\Column(length255nullabletrue)]
  89.     private ?string $address null
  90.     #[Groups(['user:read''user:create''user:update'])]
  91.     #[ORM\Column(length50nullabletrue)]
  92.     private ?string $status null;
  93.     #[ORM\OneToMany(mappedBy'user'targetEntityUserLikeList::class)]
  94.     private Collection $userLikeLists;
  95.     #[ORM\OneToMany(mappedBy'modified_user'targetEntityProducts::class)]
  96.     private Collection $products;
  97.     #[ORM\OneToMany(mappedBy'created_by'targetEntityProducts::class)]
  98.     private Collection $create_products;
  99.     #[ORM\OneToMany(mappedBy'user'targetEntityOrders::class)]
  100.     private Collection $orders;
  101.     #[ORM\OneToMany(mappedBy'manager'targetEntityOrders::class)]
  102.     private Collection $managerOrders;
  103.     #[Groups(['user:read''user:create''user:update''read''account:read'])]
  104.     #[ORM\Column(length255nullabletrue)]
  105.     private ?string $email null;
  106.     #[Groups(['user:read''user:create''user:update''read'])]
  107.     #[ORM\OneToMany(mappedBy'user'targetEntityAccounts::class)]
  108.     private Collection $accounts;
  109.     #[ORM\OneToMany(mappedBy'client'targetEntityLoadInvoice::class)]
  110.     private Collection $loadInvoices;
  111.     #[ORM\OneToMany(mappedBy'manager'targetEntityAccepted::class)]
  112.     private Collection $accepteds;
  113.     #[ORM\OneToMany(mappedBy'modified_user'targetEntityAcceptedProduct::class)]
  114.     private Collection $n;
  115.     #[ORM\Column(length20nullabletrue)]
  116.     #[Groups(['user:read''user:create''user:update''order:read''order_product:read'])]
  117.     private ?string $codeUser null;
  118.     #[ORM\Column(length20nullabletrue)]
  119.     #[Groups(['user:read''user:create''user:update''order:read''order_product:read'])]
  120.     private ?string $codeManager null;
  121.     #[ORM\OneToMany(mappedBy'manager'targetEntityAccounts::class)]
  122.     private Collection $managerAccounts;
  123.     #[ORM\OneToMany(mappedBy'client'targetEntityPreOrder::class)]
  124.     private Collection $preOrders;
  125.     #[ORM\OneToMany(mappedBy'manager'targetEntityPreOrder::class)]
  126.     private Collection $ManagerPreOrders;
  127.     #[Groups(['user:read''user:create''user:update''read''account:read'])]
  128.     #[ORM\Column(length255nullabletrue)]
  129.     private ?string $workSchedule null;
  130.     #[Groups(['user:read''user:create''user:update''read''account:read'])]
  131.     #[ORM\Column(length255nullabletrue)]
  132.     private ?string $telegram null;
  133.     #[Groups(['user:read''user:create''user:update''read''account:read'])]
  134.     #[ORM\Column(length255nullabletrue)]
  135.     private ?string $viber null;
  136.     #[Groups(['user:read''user:create''user:update''read''account:read'])]
  137.     #[ORM\OneToMany(mappedBy'users'targetEntityMediaObject::class)]
  138.     private Collection $mediaObjects;
  139.     #[ORM\ManyToMany(targetEntityCoupons::class, mappedBy'users')]
  140.     private Collection $coupons;
  141.     #[ORM\OneToMany(mappedBy'manager'targetEntityProductBalanceInStorage::class)]
  142.     private Collection $productBalanceInStorages;
  143.     #[Groups(['user:read''user:create''user:update'])]
  144.     #[ORM\ManyToOne(inversedBy'users')]
  145.     private ?Location $location null;
  146.     public function __construct()
  147.     {
  148.         $this->userLikeLists = new ArrayCollection();
  149.         $this->products = new ArrayCollection();
  150.         $this->create_products = new ArrayCollection();
  151.         $this->orders = new ArrayCollection();
  152.         $this->managerOrders = new ArrayCollection();
  153.         $this->accounts = new ArrayCollection();
  154.         $this->loadInvoices = new ArrayCollection();
  155.         $this->accepteds = new ArrayCollection();
  156.         $this->= new ArrayCollection();
  157.         $this->managerAccounts = new ArrayCollection();
  158.         $this->preOrders = new ArrayCollection();
  159.         $this->ManagerPreOrders = new ArrayCollection();
  160.         $this->mediaObjects = new ArrayCollection();
  161.         $this->coupons = new ArrayCollection();
  162.         $this->productBalanceInStorages = new ArrayCollection();
  163.     }
  164.     public function getId(): ?int
  165.     {
  166.         return $this->id;
  167.     }
  168.     /**
  169.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  170.      */
  171.     public function getUsername(): string
  172.     {
  173.         return (string) $this->username;
  174.     }
  175.     public function setUsername(string $username): self
  176.     {
  177.         $this->username $username;
  178.         return $this;
  179.     }
  180.     /**
  181.      * A visual identifier that represents this user.
  182.      *
  183.      * @see UserInterface
  184.      */
  185.     public function getUserIdentifier(): string
  186.     {
  187.         return (string) $this->username;
  188.     }
  189.     /**
  190.      * @see UserInterface
  191.      */
  192.     public function getRoles(): array
  193.     {
  194.         $roles $this->roles;
  195.         // guarantee every user at least has ROLE_USER
  196.         $roles[] = 'ROLE_USER';
  197.         return array_unique($roles);
  198.     }
  199.     public function setRoles(array $roles): self
  200.     {
  201.         $this->roles $roles;
  202.         return $this;
  203.     }
  204.     /**
  205.      * @see PasswordAuthenticatedUserInterface
  206.      */
  207.     public function getPassword(): string
  208.     {
  209.         return $this->password;
  210.     }
  211.     public function setPassword(string $password): self
  212.     {
  213.         $this->password $password;
  214.         return $this;
  215.     }
  216.     public function getPlainPassword(): ?string
  217.     {
  218.         return $this->plainPassword;
  219.     }
  220.     public function setPlainPassword(?string $plainPassword): self
  221.     {
  222.         $this->plainPassword $plainPassword;
  223.         return $this;
  224.     }
  225.     /**
  226.      * Returning a salt is only needed, if you are not using a modern
  227.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  228.      *
  229.      * @see UserInterface
  230.      */
  231.     public function getSalt(): ?string
  232.     {
  233.         return null;
  234.     }
  235.     /**
  236.      * @see UserInterface
  237.      */
  238.     public function eraseCredentials()
  239.     {
  240.         // If you store any temporary, sensitive data on the user, clear it here
  241.         $this->plainPassword null;
  242.     }
  243.     public function getManagerId(): ?self
  244.     {
  245.         return $this->manager;
  246.     }
  247.     public function setManagerId(?self $manager): self
  248.     {
  249.         $this->manager $manager;
  250.         return $this;
  251.     }
  252.     
  253.     public function getFirstName(): ?string
  254.     {
  255.         return $this->firstName;
  256.     }
  257.     public function setFirstName(string $firstName): self
  258.     {
  259.         $this->firstName $firstName;
  260.         return $this;
  261.     }
  262.     public function getLastName(): ?string
  263.     {
  264.         return $this->lastName;
  265.     }
  266.     public function setLastName(string $lastName): self
  267.     {
  268.         $this->lastName $lastName;
  269.         return $this;
  270.     }
  271.     public function getPhone(): ?string
  272.     {
  273.         return $this->phone;
  274.     }
  275.     public function setPhone(?string $phone): self
  276.     {
  277.         $this->phone $phone;
  278.         return $this;
  279.     }
  280.     public function getAddress(): ?string
  281.     {
  282.         return $this->address;
  283.     }
  284.     public function setAddress(?string $address): self
  285.     {
  286.         $this->address $address;
  287.         return $this;
  288.     }
  289.     public function getStatus(): ?string
  290.     {
  291.         return $this->status;
  292.     }
  293.     public function setStatus(?string $status): self
  294.     {
  295.         $this->status $status;
  296.         return $this;
  297.     }
  298.     /**
  299.      * @return Collection<int, UserLikeList>
  300.      */
  301.     public function getUserLikeLists(): Collection
  302.     {
  303.         return $this->userLikeLists;
  304.     }
  305.     public function addUserLikeList(UserLikeList $userLikeList): self
  306.     {
  307.         if (!$this->userLikeLists->contains($userLikeList)) {
  308.             $this->userLikeLists->add($userLikeList);
  309.             $userLikeList->setUserId($this);
  310.         }
  311.         return $this;
  312.     }
  313.     public function removeUserLikeList(UserLikeList $userLikeList): self
  314.     {
  315.         if ($this->userLikeLists->removeElement($userLikeList)) {
  316.             // set the owning side to null (unless already changed)
  317.             if ($userLikeList->getUserId() === $this) {
  318.                 $userLikeList->setUserId(null);
  319.             }
  320.         }
  321.         return $this;
  322.     }
  323.     /**
  324.      * @return Collection<int, Products>
  325.      */
  326.     public function getProducts(): Collection
  327.     {
  328.         return $this->products;
  329.     }
  330.     public function addProduct(Products $product): self
  331.     {
  332.         if (!$this->products->contains($product)) {
  333.             $this->products->add($product);
  334.             $product->setModifiedUserId($this);
  335.         }
  336.         return $this;
  337.     }
  338.     // public function removeProduct(Products $product): self
  339.     // {
  340.     //     if ($this->products->removeElement($product)) {
  341.     //         // set the owning side to null (unless already changed)
  342.     //         if ($product->getModifiedUserId() === $this) {
  343.     //             $product->setModifiedUserId(null);
  344.     //         }
  345.     //     }
  346.     //     return $this;
  347.     // }
  348.     /**
  349.      * @return Collection<int, Products>
  350.      */
  351.     public function getCreateProducts(): Collection
  352.     {
  353.         return $this->create_products;
  354.     }
  355.     public function addCreateProduct(Products $createProduct): self
  356.     {
  357.         if (!$this->create_products->contains($createProduct)) {
  358.             $this->create_products->add($createProduct);
  359.             $createProduct->setCreatedBy($this);
  360.         }
  361.         return $this;
  362.     }
  363.     // public function removeCreateProduct(Products $createProduct): self
  364.     // {
  365.     //     if ($this->create_products->removeElement($createProduct)) {
  366.     //         // set the owning side to null (unless already changed)
  367.     //         if ($createProduct->getCreatedBy() === $this) {
  368.     //             $createProduct->setCreatedBy(null);
  369.     //         }
  370.     //     }
  371.     //     return $this;
  372.     // }
  373.     /**
  374.      * @return Collection<int, Orders>
  375.      */
  376.     public function getOrders(): Collection
  377.     {
  378.         return $this->orders;
  379.     }
  380.     public function addOrder(Orders $order): self
  381.     {
  382.         if (!$this->orders->contains($order)) {
  383.             $this->orders->add($order);
  384.             $order->setUserId($this);
  385.         }
  386.         return $this;
  387.     }
  388.     // public function removeOrder(Orders $order): self
  389.     // {
  390.     //     if ($this->orders->removeElement($order)) {
  391.     //         // set the owning side to null (unless already changed)
  392.     //         if ($order->getUserId() === $this) {
  393.     //             $order->setUserId(null);
  394.     //         }
  395.     //     }
  396.     //     return $this;
  397.     // }
  398.     /**
  399.      * @return Collection<int, Orders>
  400.      */
  401.     public function getManagerOrders(): Collection
  402.     {
  403.         return $this->managerOrders;
  404.     }
  405.     public function addManagerOrder(Orders $managerOrder): self
  406.     {
  407.         if (!$this->managerOrders->contains($managerOrder)) {
  408.             $this->managerOrders->add($managerOrder);
  409.             $managerOrder->setManagerId($this);
  410.         }
  411.         return $this;
  412.     }
  413.     // public function removeManagerOrder(Orders $managerOrder): self
  414.     // {
  415.     //     if ($this->managerOrders->removeElement($managerOrder)) {
  416.     //         // set the owning side to null (unless already changed)
  417.     //         if ($managerOrder->getManagerId() === $this) {
  418.     //             $managerOrder->setManagerId(null);
  419.     //         }
  420.     //     }
  421.     //     return $this;
  422.     // }
  423.     public function getEmail(): ?string
  424.     {
  425.         return $this->email;
  426.     }
  427.     public function setEmail(?string $email): self
  428.     {
  429.         $this->email $email;
  430.         return $this;
  431.     }
  432.     /**
  433.      * @return Collection<int, Accounts>
  434.      */
  435.     public function getAccounts(): Collection
  436.     {
  437.         return $this->accounts;
  438.     }
  439.     public function addAccount(Accounts $account): self
  440.     {
  441.         if (!$this->accounts->contains($account)) {
  442.             $this->accounts->add($account);
  443.             $account->setUserId($this);
  444.         }
  445.         return $this;
  446.     }
  447.     public function removeAccount(Accounts $account): self
  448.     {
  449.         if ($this->accounts->removeElement($account)) {
  450.             // set the owning side to null (unless already changed)
  451.             if ($account->getUserId() === $this) {
  452.                 $account->setUserId(null);
  453.             }
  454.         }
  455.         return $this;
  456.     }
  457.     /**
  458.      * @return Collection<int, LoadInvoice>
  459.      */
  460.     public function getLoadInvoices(): Collection
  461.     {
  462.         return $this->loadInvoices;
  463.     }
  464.     public function addLoadInvoice(LoadInvoice $loadInvoice): self
  465.     {
  466.         if (!$this->loadInvoices->contains($loadInvoice)) {
  467.             $this->loadInvoices->add($loadInvoice);
  468.             $loadInvoice->setClient($this);
  469.         }
  470.         return $this;
  471.     }
  472.     public function removeLoadInvoice(LoadInvoice $loadInvoice): self
  473.     {
  474.         if ($this->loadInvoices->removeElement($loadInvoice)) {
  475.             // set the owning side to null (unless already changed)
  476.             if ($loadInvoice->getClient() === $this) {
  477.                 $loadInvoice->setClient(null);
  478.             }
  479.         }
  480.         return $this;
  481.     }
  482.     /**
  483.      * @return Collection<int, Accepted>
  484.      */
  485.     public function getAccepteds(): Collection
  486.     {
  487.         return $this->accepteds;
  488.     }
  489.     public function addAccepted(Accepted $accepted): self
  490.     {
  491.         if (!$this->accepteds->contains($accepted)) {
  492.             $this->accepteds->add($accepted);
  493.             $accepted->setManager($this);
  494.         }
  495.         return $this;
  496.     }
  497.     public function removeAccepted(Accepted $accepted): self
  498.     {
  499.         if ($this->accepteds->removeElement($accepted)) {
  500.             // set the owning side to null (unless already changed)
  501.             if ($accepted->getManager() === $this) {
  502.                 $accepted->setManager(null);
  503.             }
  504.         }
  505.         return $this;
  506.     }
  507.     /**
  508.      * @return Collection<int, AcceptedProduct>
  509.      */
  510.     public function getN(): Collection
  511.     {
  512.         return $this->n;
  513.     }
  514.     public function addN(AcceptedProduct $n): self
  515.     {
  516.         if (!$this->n->contains($n)) {
  517.             $this->n->add($n);
  518.             $n->setModifiedUser($this);
  519.         }
  520.         return $this;
  521.     }
  522.     public function removeN(AcceptedProduct $n): self
  523.     {
  524.         if ($this->n->removeElement($n)) {
  525.             // set the owning side to null (unless already changed)
  526.             if ($n->getModifiedUser() === $this) {
  527.                 $n->setModifiedUser(null);
  528.             }
  529.         }
  530.         return $this;
  531.     }
  532.     public function getCodeUser(): ?string
  533.     {
  534.         return $this->codeUser;
  535.     }
  536.     public function setCodeUser(string $codeUser): self
  537.     {
  538.         $this->codeUser $codeUser;
  539.         return $this;
  540.     }
  541.     public function getCodeManager(): ?string
  542.     {
  543.         return $this->codeManager;
  544.     }
  545.     public function setCodeManager(string $codeManager): self
  546.     {
  547.         $this->codeManager $codeManager;
  548.         return $this;
  549.     }
  550.     /**
  551.      * @return Collection<int, Accounts>
  552.      */
  553.     public function getManagerAccounts(): Collection
  554.     {
  555.         return $this->managerAccounts;
  556.     }
  557.     public function addManagerAccount(Accounts $managerAccount): self
  558.     {
  559.         if (!$this->managerAccounts->contains($managerAccount)) {
  560.             $this->managerAccounts->add($managerAccount);
  561.             $managerAccount->setManager($this);
  562.         }
  563.         return $this;
  564.     }
  565.     public function removeManagerAccount(Accounts $managerAccount): self
  566.     {
  567.         if ($this->managerAccounts->removeElement($managerAccount)) {
  568.             // set the owning side to null (unless already changed)
  569.             if ($managerAccount->getManager() === $this) {
  570.                 $managerAccount->setManager(null);
  571.             }
  572.         }
  573.         return $this;
  574.     }
  575.     /**
  576.      * @return Collection<int, PreOrder>
  577.      */
  578.     public function getPreOrders(): Collection
  579.     {
  580.         return $this->preOrders;
  581.     }
  582.     public function addPreOrder(PreOrder $preOrder): self
  583.     {
  584.         if (!$this->preOrders->contains($preOrder)) {
  585.             $this->preOrders->add($preOrder);
  586.             $preOrder->setClient($this);
  587.         }
  588.         return $this;
  589.     }
  590.     public function removePreOrder(PreOrder $preOrder): self
  591.     {
  592.         if ($this->preOrders->removeElement($preOrder)) {
  593.             // set the owning side to null (unless already changed)
  594.             if ($preOrder->getClient() === $this) {
  595.                 $preOrder->setClient(null);
  596.             }
  597.         }
  598.         return $this;
  599.     }
  600.     /**
  601.      * @return Collection<int, PreOrder>
  602.      */
  603.     public function getManagerPreOrders(): Collection
  604.     {
  605.         return $this->ManagerPreOrders;
  606.     }
  607.     public function addManagerPreOrder(PreOrder $managerPreOrder): self
  608.     {
  609.         if (!$this->ManagerPreOrders->contains($managerPreOrder)) {
  610.             $this->ManagerPreOrders->add($managerPreOrder);
  611.             $managerPreOrder->setManager($this);
  612.         }
  613.         return $this;
  614.     }
  615.     public function removeManagerPreOrder(PreOrder $managerPreOrder): self
  616.     {
  617.         if ($this->ManagerPreOrders->removeElement($managerPreOrder)) {
  618.             // set the owning side to null (unless already changed)
  619.             if ($managerPreOrder->getManager() === $this) {
  620.                 $managerPreOrder->setManager(null);
  621.             }
  622.         }
  623.         return $this;
  624.     }
  625.     public function getWorkSchedule(): ?string
  626.     {
  627.         return $this->workSchedule;
  628.     }
  629.     public function setWorkSchedule(?string $workSchedule): self
  630.     {
  631.         $this->workSchedule $workSchedule;
  632.         return $this;
  633.     }
  634.     public function getTelegram(): ?string
  635.     {
  636.         return $this->telegram;
  637.     }
  638.     public function setTelegram(?string $telegram): self
  639.     {
  640.         $this->telegram $telegram;
  641.         return $this;
  642.     }
  643.     public function getViber(): ?string
  644.     {
  645.         return $this->viber;
  646.     }
  647.     public function setViber(?string $viber): self
  648.     {
  649.         $this->viber $viber;
  650.         return $this;
  651.     }
  652.     /**
  653.      * @return Collection<int, MediaObject>
  654.      */
  655.     public function getMediaObjects(): Collection
  656.     {
  657.         return $this->mediaObjects;
  658.     }
  659.     public function addMediaObject(MediaObject $mediaObject): self
  660.     {
  661.         if (!$this->mediaObjects->contains($mediaObject)) {
  662.             $this->mediaObjects->add($mediaObject);
  663.             $mediaObject->setUsers($this);
  664.         }
  665.         return $this;
  666.     }
  667.     public function removeMediaObject(MediaObject $mediaObject): self
  668.     {
  669.         if ($this->mediaObjects->removeElement($mediaObject)) {
  670.             // set the owning side to null (unless already changed)
  671.             if ($mediaObject->getUsers() === $this) {
  672.                 $mediaObject->setUsers(null);
  673.             }
  674.         }
  675.         return $this;
  676.     }
  677.     /**
  678.      * @return Collection<int, Coupons>
  679.      */
  680.     public function getCoupons(): Collection
  681.     {
  682.         return $this->coupons;
  683.     }
  684.     public function addCoupon(Coupons $coupon): self
  685.     {
  686.         if (!$this->coupons->contains($coupon)) {
  687.             $this->coupons->add($coupon);
  688.             $coupon->addUser($this);
  689.         }
  690.         return $this;
  691.     }
  692.     public function removeCoupon(Coupons $coupon): self
  693.     {
  694.         if ($this->coupons->removeElement($coupon)) {
  695.             $coupon->removeUser($this);
  696.         }
  697.         return $this;
  698.     }
  699.     /**
  700.      * @return Collection<int, ProductBalanceInStorage>
  701.      */
  702.     public function getProductBalanceInStorages(): Collection
  703.     {
  704.         return $this->productBalanceInStorages;
  705.     }
  706.     public function addProductBalanceInStorage(ProductBalanceInStorage $productBalanceInStorage): self
  707.     {
  708.         if (!$this->productBalanceInStorages->contains($productBalanceInStorage)) {
  709.             $this->productBalanceInStorages->add($productBalanceInStorage);
  710.             $productBalanceInStorage->setManager($this);
  711.         }
  712.         return $this;
  713.     }
  714.     public function removeProductBalanceInStorage(ProductBalanceInStorage $productBalanceInStorage): self
  715.     {
  716.         if ($this->productBalanceInStorages->removeElement($productBalanceInStorage)) {
  717.             // set the owning side to null (unless already changed)
  718.             if ($productBalanceInStorage->getManager() === $this) {
  719.                 $productBalanceInStorage->setManager(null);
  720.             }
  721.         }
  722.         return $this;
  723.     }
  724.     public function getLocation(): ?Location
  725.     {
  726.         return $this->location;
  727.     }
  728.     public function setLocation(?Location $location): self
  729.     {
  730.         $this->location $location;
  731.         return $this;
  732.     }
  733. }