преди 4 години
преди 4 години
преди 4 години
преди 4 години
преди 4 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <?php
  2. namespace Lc\ShopBundle\Model;
  3. use App\Entity\User;
  4. use App\Entity\UserPointSale;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Lc\ShopBundle\Context\FilterMultipleMerchantsInterface;
  9. use Lc\ShopBundle\Context\OrderAmountMinInterface;
  10. /**
  11. * @ORM\MappedSuperclass()
  12. */
  13. abstract class PointSale extends AbstractDocumentEntity implements FilterMultipleMerchantsInterface, OrderAmountMinInterface
  14. {
  15. use OrderAmountMin;
  16. /**
  17. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\MerchantInterface", inversedBy="pointSales")
  18. */
  19. protected $merchants;
  20. /**
  21. * @ORM\Column(type="string", length=63, nullable=true)
  22. */
  23. protected $code;
  24. /**
  25. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\PointSaleDayInfoInterface", mappedBy="pointSale", orphanRemoval=true)
  26. */
  27. protected $pointSaleDayInfos;
  28. /**
  29. * @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\AddressInterface", inversedBy="pointSale", cascade={"persist", "remove"})
  30. * @ORM\JoinColumn(nullable=false)
  31. */
  32. protected $address;
  33. /**
  34. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\UserPointSaleInterface", mappedBy="pointSale", orphanRemoval=true)
  35. */
  36. protected $userPointSales;
  37. public function __construct()
  38. {
  39. $this->merchants = new ArrayCollection();
  40. $this->pointSaleDayInfos = new ArrayCollection();
  41. $this->userPointSales = new ArrayCollection();
  42. }
  43. public function __toString()
  44. {
  45. return $this->getTitle() ;
  46. }
  47. public function labelAdminChoice()
  48. {
  49. return $this->getTitle();
  50. }
  51. /**
  52. * @return Collection|Merchant[]
  53. */
  54. public function getMerchants(): Collection
  55. {
  56. return $this->merchants;
  57. }
  58. public function addMerchant(Merchant $merchant): self
  59. {
  60. if (!$this->merchants->contains($merchant)) {
  61. $this->merchants[] = $merchant;
  62. }
  63. return $this;
  64. }
  65. public function removeMerchant(Merchant $merchant): self
  66. {
  67. if ($this->merchants->contains($merchant)) {
  68. $this->merchants->removeElement($merchant);
  69. }
  70. return $this;
  71. }
  72. public function getCode(): ?string
  73. {
  74. return $this->code;
  75. }
  76. public function setCode(?string $code): self
  77. {
  78. $this->code = $code;
  79. return $this;
  80. }
  81. /**
  82. * @return Collection|PointSaleDayInfo[]
  83. */
  84. public function getPointSaleDayInfos(): Collection
  85. {
  86. return $this->pointSaleDayInfos;
  87. }
  88. public function addPointSaleDayInfo(PointSaleDayInfo $pointSaleDayInfo): self
  89. {
  90. if (!$this->pointSaleDayInfos->contains($pointSaleDayInfo)) {
  91. $this->pointSaleDayInfos[] = $pointSaleDayInfo;
  92. $pointSaleDayInfo->setPointSale($this);
  93. }
  94. return $this;
  95. }
  96. public function removePointSaleDayInfo(PointSaleDayInfo $pointSaleDayInfo): self
  97. {
  98. if ($this->pointSaleDayInfos->contains($pointSaleDayInfo)) {
  99. $this->pointSaleDayInfos->removeElement($pointSaleDayInfo);
  100. // set the owning side to null (unless already changed)
  101. if ($pointSaleDayInfo->getPointSale() === $this) {
  102. $pointSaleDayInfo->setPointSale(null);
  103. }
  104. }
  105. return $this;
  106. }
  107. public function getAddress(): ?Address
  108. {
  109. return $this->address;
  110. }
  111. public function setAddress(Address $address): self
  112. {
  113. $this->address = $address;
  114. return $this;
  115. }
  116. /**
  117. * @return Collection|UserPointSale[]
  118. */
  119. public function getUserPointSales(): Collection
  120. {
  121. return $this->userPointSales;
  122. }
  123. public function addUserPointSale(UserPointSale $userPointSale): self
  124. {
  125. if (!$this->userPointSales->contains($userPointSale)) {
  126. $this->userPointSales[] = $userPointSale;
  127. $userPointSale->setPointSale($this);
  128. }
  129. return $this;
  130. }
  131. public function removeUserPointSale(UserPointSale $userPointSale): self
  132. {
  133. if ($this->userPointSales->contains($userPointSale)) {
  134. $this->userPointSales->removeElement($userPointSale);
  135. // set the owning side to null (unless already changed)
  136. if ($userPointSale->getPointSale() === $this) {
  137. $userPointSale->setPointSale(null);
  138. }
  139. }
  140. return $this;
  141. }
  142. }