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.

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