Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

161 lines
4.0KB

  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
  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\OneToOne(targetEntity="Lc\CaracoleBundle\Model\Address\AddressInterface", inversedBy="pointSale", cascade={"persist", "remove"})
  31. * @ORM\JoinColumn(nullable=false)
  32. */
  33. protected $address;
  34. /**
  35. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\User\UserPointSaleInterface", mappedBy="pointSale", orphanRemoval=true)
  36. */
  37. protected $userPointSales;
  38. /**
  39. * @ORM\ManyToOne(targetEntity=File::class, cascade={"persist", "remove"})
  40. */
  41. protected $image;
  42. public function __construct()
  43. {
  44. $this->merchants = 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. public function getAddress(): ?AddressInterface
  86. {
  87. return $this->address;
  88. }
  89. public function setAddress(AddressInterface $address): self
  90. {
  91. $this->address = $address;
  92. return $this;
  93. }
  94. /**
  95. * @return Collection|UserPointSaleInterface[]
  96. */
  97. public function getUserPointSales(): Collection
  98. {
  99. return $this->userPointSales;
  100. }
  101. public function addUserPointSale(UserPointSaleInterface $userPointSale): self
  102. {
  103. if (!$this->userPointSales->contains($userPointSale)) {
  104. $this->userPointSales[] = $userPointSale;
  105. $userPointSale->setPointSale($this);
  106. }
  107. return $this;
  108. }
  109. public function removeUserPointSale(UserPointSaleInterface $userPointSale): self
  110. {
  111. if ($this->userPointSales->contains($userPointSale)) {
  112. $this->userPointSales->removeElement($userPointSale);
  113. // set the owning side to null (unless already changed)
  114. if ($userPointSale->getPointSale() === $this) {
  115. $userPointSale->setPointSale(null);
  116. }
  117. }
  118. return $this;
  119. }
  120. public function getImage(): ?File
  121. {
  122. return $this->image;
  123. }
  124. public function setImage(?File $image): self
  125. {
  126. $this->image = $image;
  127. return $this;
  128. }
  129. }