You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

192 lines
5.1KB

  1. <?php
  2. namespace Lc\ShopBundle\Model;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Lc\ShopBundle\Context\FilterMerchantInterface;
  7. use Lc\ShopBundle\Context\ReductionCatalogInterface;
  8. use Lc\ShopBundle\Context\ReductionInterface;
  9. use phpDocumentor\Reflection\Types\Integer;
  10. /**
  11. * @ORM\MappedSuperclass()
  12. */
  13. abstract class ReductionCatalog extends AbstractDocumentEntity implements ReductionCatalogInterface, FilterMerchantInterface
  14. {
  15. use ReductionTrait;
  16. /**
  17. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface", inversedBy="productFamilies")
  18. * @ORM\JoinColumn(nullable=false)
  19. */
  20. protected $merchant;
  21. /**
  22. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\ProductFamilyInterface")
  23. */
  24. protected $productFamilies;
  25. /**
  26. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\ProductCategoryInterface")
  27. */
  28. protected $productCategories;
  29. /**
  30. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\GroupUserInterface")
  31. */
  32. protected $groupUsers;
  33. /**
  34. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\UserInterface")
  35. */
  36. protected $users;
  37. /*
  38. * @ORM\Column(type="smallint")
  39. */
  40. // protected $fromQuantity = 1;
  41. public function __construct()
  42. {
  43. $this->productFamilies = new ArrayCollection();
  44. $this->groupUsers = new ArrayCollection();
  45. $this->productCategories = new ArrayCollection();
  46. $this->users = new ArrayCollection();
  47. }
  48. public function getMerchant(): ?Merchant
  49. {
  50. return $this->merchant;
  51. }
  52. public function setMerchant(?Merchant $merchant): self
  53. {
  54. $this->merchant = $merchant;
  55. return $this;
  56. }
  57. /**
  58. * @return Collection|ProductFamily[]
  59. */
  60. public function getProductFamilies(): Collection
  61. {
  62. return $this->productFamilies;
  63. }
  64. public function addProductFamily(ProductFamily $productFamily): self
  65. {
  66. if (!$this->productFamilies->contains($productFamily)) {
  67. $this->productFamilies[] = $productFamily;
  68. }
  69. return $this;
  70. }
  71. public function removeProductFamily(ProductFamily $productFamily): self
  72. {
  73. if ($this->productFamilies->contains($productFamily)) {
  74. $this->productFamilies->removeElement($productFamily);
  75. }
  76. return $this;
  77. }
  78. /**
  79. * @return Collection|GroupUser[]
  80. */
  81. public function getGroupUsers(): Collection
  82. {
  83. return $this->groupUsers;
  84. }
  85. public function addGroupUser(GroupUser $groupUser): self
  86. {
  87. if (!$this->groupUsers->contains($groupUser)) {
  88. $this->groupUsers[] = $groupUser;
  89. }
  90. return $this;
  91. }
  92. public function removeGroupUser(GroupUser $groupUser): self
  93. {
  94. if ($this->groupUsers->contains($groupUser)) {
  95. $this->groupUsers->removeElement($groupUser);
  96. }
  97. return $this;
  98. }
  99. /**
  100. * @return Collection|ProductCategory[]
  101. */
  102. public function getProductCategories(): Collection
  103. {
  104. return $this->productCategories;
  105. }
  106. public function addProductCategory(ProductCategory $productCategory): self
  107. {
  108. if (!$this->productCategories->contains($productCategory)) {
  109. $this->productCategories[] = $productCategory;
  110. }
  111. return $this;
  112. }
  113. public function removeProductCategory(ProductCategory $productCategory): self
  114. {
  115. if ($this->productCategories->contains($productCategory)) {
  116. $this->productCategories->removeElement($productCategory);
  117. }
  118. return $this;
  119. }
  120. /**
  121. * @return Collection|User[]
  122. */
  123. public function getUsers(): Collection
  124. {
  125. return $this->users;
  126. }
  127. public function addUser(User $user): self
  128. {
  129. if (!$this->users->contains($user)) {
  130. $this->users[] = $user;
  131. }
  132. return $this;
  133. }
  134. public function removeUser(User $user): self
  135. {
  136. if ($this->users->contains($user)) {
  137. $this->users->removeElement($user);
  138. }
  139. return $this;
  140. }
  141. /*public function getFromQuantity(): ?int
  142. {
  143. return $this->fromQuantity;
  144. }
  145. public function setFromQuantity(int $fromQuantity): self
  146. {
  147. $this->fromQuantity = $fromQuantity;
  148. return $this;
  149. }*/
  150. }