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.

PointSaleModel.php 4.9KB

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