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.

132 line
3.6KB

  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. /**
  7. * @ORM\MappedSuperclass()
  8. */
  9. abstract class PointSale extends AbstractDocumentEntity
  10. {
  11. /**
  12. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\MerchantInterface", inversedBy="pointSales")
  13. */
  14. protected $merchant;
  15. /**
  16. * @ORM\Column(type="string", length=63, nullable=true)
  17. */
  18. protected $code;
  19. /**
  20. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\PointSaleDayInfoInterface", mappedBy="pointSale", orphanRemoval=true)
  21. */
  22. protected $pointSaleDayInfos;
  23. /**
  24. * @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\AddressInterface", inversedBy="pointSale", cascade={"persist", "remove"})
  25. * @ORM\JoinColumn(nullable=false)
  26. */
  27. protected $address;
  28. public function labelAdminChoice(){
  29. return $this->getTitle();
  30. }
  31. public function __construct()
  32. {
  33. $this->merchant = new ArrayCollection();
  34. $this->pointSaleDayInfos = new ArrayCollection();
  35. }
  36. public function __toString()
  37. {
  38. return $this->getTitle() ;
  39. }
  40. /**
  41. * @return Collection|Merchant[]
  42. */
  43. public function getMerchant(): Collection
  44. {
  45. return $this->merchant;
  46. }
  47. public function addMerchant(Merchant $merchant): self
  48. {
  49. if (!$this->merchant->contains($merchant)) {
  50. $this->merchant[] = $merchant;
  51. }
  52. return $this;
  53. }
  54. public function removeMerchant(Merchant $merchant): self
  55. {
  56. if ($this->merchant->contains($merchant)) {
  57. $this->merchant->removeElement($merchant);
  58. }
  59. return $this;
  60. }
  61. public function getCode(): ?string
  62. {
  63. return $this->code;
  64. }
  65. public function setCode(?string $code): self
  66. {
  67. $this->code = $code;
  68. return $this;
  69. }
  70. /**
  71. * @return Collection|PointSaleDayInfo[]
  72. */
  73. public function getPointSaleDayInfos(): Collection
  74. {
  75. return $this->pointSaleDayInfos;
  76. }
  77. public function addPointSaleDayInfo(PointSaleDayInfo $pointSaleDayInfo): self
  78. {
  79. if (!$this->pointSaleDayInfos->contains($pointSaleDayInfo)) {
  80. $this->pointSaleDayInfos[] = $pointSaleDayInfo;
  81. $pointSaleDayInfo->setPointSale($this);
  82. }
  83. return $this;
  84. }
  85. public function removePointSaleDayInfo(PointSaleDayInfo $pointSaleDayInfo): self
  86. {
  87. if ($this->pointSaleDayInfos->contains($pointSaleDayInfo)) {
  88. $this->pointSaleDayInfos->removeElement($pointSaleDayInfo);
  89. // set the owning side to null (unless already changed)
  90. if ($pointSaleDayInfo->getPointSale() === $this) {
  91. $pointSaleDayInfo->setPointSale(null);
  92. }
  93. }
  94. return $this;
  95. }
  96. public function getAddress(): ?Address
  97. {
  98. return $this->address;
  99. }
  100. public function setAddress(Address $address): self
  101. {
  102. $this->address = $address;
  103. return $this;
  104. }
  105. }