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.

225 line
5.7KB

  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. use App\Entity\File\File;
  14. /**
  15. * @ORM\MappedSuperclass()
  16. */
  17. abstract class PointSaleModel extends AbstractFullEntity implements FilterMultipleMerchantsInterface,
  18. OrderAmountMinInterface, PointSaleInterface
  19. {
  20. use OrderAmountMinTrait;
  21. /**
  22. * @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", inversedBy="pointSales")
  23. */
  24. protected $merchants;
  25. /**
  26. * @ORM\Column(type="string", length=63, nullable=true)
  27. */
  28. protected $code;
  29. /**
  30. * @ORM\Column(type="float")
  31. */
  32. protected $deliveryPrice;
  33. /**
  34. * @ORM\Column(type="boolean")
  35. */
  36. protected $isPublic;
  37. /**
  38. * @ORM\OneToOne(targetEntity="Lc\CaracoleBundle\Model\Address\AddressInterface", inversedBy="pointSale", cascade={"persist", "remove"})
  39. * @ORM\JoinColumn(nullable=false)
  40. */
  41. protected $address;
  42. /**
  43. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\User\UserPointSaleInterface", mappedBy="pointSale", orphanRemoval=true)
  44. */
  45. protected $userPointSales;
  46. /**
  47. * @ORM\ManyToOne(targetEntity=File::class, cascade={"persist", "remove"})
  48. */
  49. protected $image;
  50. /**
  51. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\PointSale\PointSaleSectionInterface", mappedBy="pointSale", cascade={"persist"})
  52. */
  53. protected $pointSaleSections;
  54. public function __construct()
  55. {
  56. $this->merchants = new ArrayCollection();
  57. $this->userPointSales = new ArrayCollection();
  58. $this->pointSaleSections = new ArrayCollection();
  59. }
  60. public function __toString()
  61. {
  62. return $this->getTitle();
  63. }
  64. /**
  65. * @return Collection|MerchantInterface[]
  66. */
  67. public function getMerchants(): Collection
  68. {
  69. return $this->merchants;
  70. }
  71. public function addMerchant(MerchantInterface $merchant): self
  72. {
  73. if (!$this->merchants->contains($merchant)) {
  74. $this->merchants[] = $merchant;
  75. }
  76. return $this;
  77. }
  78. public function removeMerchant(MerchantInterface $merchant): self
  79. {
  80. if ($this->merchants->contains($merchant)) {
  81. $this->merchants->removeElement($merchant);
  82. }
  83. return $this;
  84. }
  85. public function getCode(): ?string
  86. {
  87. return $this->code;
  88. }
  89. public function setCode(?string $code): self
  90. {
  91. $this->code = $code;
  92. return $this;
  93. }
  94. public function getDeliveryPrice(): ?float
  95. {
  96. return $this->deliveryPrice;
  97. }
  98. public function setDeliveryPrice(float $deliveryPrice): self
  99. {
  100. $this->deliveryPrice = $deliveryPrice;
  101. return $this;
  102. }
  103. public function getIsPublic(): ?bool
  104. {
  105. return $this->isPublic;
  106. }
  107. public function setIsPublic(bool $isPublic): self
  108. {
  109. $this->isPublic = $isPublic;
  110. return $this;
  111. }
  112. public function getAddress(): ?AddressInterface
  113. {
  114. return $this->address;
  115. }
  116. public function setAddress(AddressInterface $address): self
  117. {
  118. $this->address = $address;
  119. return $this;
  120. }
  121. /**
  122. * @return Collection|UserPointSaleInterface[]
  123. */
  124. public function getUserPointSales(): Collection
  125. {
  126. return $this->userPointSales;
  127. }
  128. public function addUserPointSale(UserPointSaleInterface $userPointSale): self
  129. {
  130. if (!$this->userPointSales->contains($userPointSale)) {
  131. $this->userPointSales[] = $userPointSale;
  132. $userPointSale->setPointSale($this);
  133. }
  134. return $this;
  135. }
  136. public function removeUserPointSale(UserPointSaleInterface $userPointSale): self
  137. {
  138. if ($this->userPointSales->contains($userPointSale)) {
  139. $this->userPointSales->removeElement($userPointSale);
  140. // set the owning side to null (unless already changed)
  141. if ($userPointSale->getPointSale() === $this) {
  142. $userPointSale->setPointSale(null);
  143. }
  144. }
  145. return $this;
  146. }
  147. public function getImage(): ?File
  148. {
  149. return $this->image;
  150. }
  151. public function setImage(?File $image): self
  152. {
  153. $this->image = $image;
  154. return $this;
  155. }
  156. /**
  157. * @return Collection|PointSaleSectionInterface[]
  158. */
  159. public function getPointSaleSections(): Collection
  160. {
  161. return $this->pointSaleSections;
  162. }
  163. public function addPointSaleSection(PointSaleSectionInterface $pointSaleSection): self
  164. {
  165. if (!$this->pointSaleSections->contains($pointSaleSection)) {
  166. $this->pointSaleSections[] = $pointSaleSection;
  167. $pointSaleSection->setPointSale($this);
  168. }
  169. return $this;
  170. }
  171. public function removePointSaleSection(PointSaleSectionInterface $pointSaleSection): self
  172. {
  173. if ($this->pointSaleSections->removeElement($pointSaleSection)) {
  174. // set the owning side to null (unless already changed)
  175. if ($pointSaleSection->getPointSale() === $this) {
  176. $pointSaleSection->setPointSale(null);
  177. }
  178. }
  179. return $this;
  180. }
  181. }