154 lines
3.5KB

  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. trait ReductionPropertyTrait
  7. {
  8. /**
  9. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\UserInterface")
  10. */
  11. protected $users;
  12. /**
  13. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\GroupUserInterface")
  14. */
  15. protected $groupUsers;
  16. /**
  17. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface", inversedBy="productFamilies")
  18. * @ORM\JoinColumn(nullable=false)
  19. */
  20. protected $merchant;
  21. /**
  22. * @ORM\Column(type="datetime", nullable=true)
  23. */
  24. protected $dateStart;
  25. /**
  26. * @ORM\Column(type="datetime", nullable=true)
  27. */
  28. protected $dateEnd;
  29. /**
  30. * @ORM\Column(type="boolean")
  31. */
  32. protected $permanent;
  33. public function __construct()
  34. {
  35. $this->users = new ArrayCollection();
  36. $this->groupUsers = new ArrayCollection();
  37. }
  38. public function getMerchant(): ?Merchant
  39. {
  40. return $this->merchant;
  41. }
  42. public function setMerchant(?Merchant $merchant): self
  43. {
  44. $this->merchant = $merchant;
  45. return $this;
  46. }
  47. /**
  48. * @return Collection|User[]
  49. */
  50. public function getUsers(): Collection
  51. {
  52. return $this->users;
  53. }
  54. public function addUser(User $user): self
  55. {
  56. if (!$this->users->contains($user)) {
  57. $this->users[] = $user;
  58. }
  59. return $this;
  60. }
  61. public function removeUser(User $user): self
  62. {
  63. if ($this->users->contains($user)) {
  64. $this->users->removeElement($user);
  65. }
  66. return $this;
  67. }
  68. /**
  69. * @return Collection|GroupUser[]
  70. */
  71. public function getGroupUsers(): Collection
  72. {
  73. return $this->groupUsers;
  74. }
  75. public function addGroupUser(GroupUser $groupUser): self
  76. {
  77. if (!$this->groupUsers->contains($groupUser)) {
  78. $this->groupUsers[] = $groupUser;
  79. }
  80. return $this;
  81. }
  82. public function removeGroupUser(GroupUser $groupUser): self
  83. {
  84. if ($this->groupUsers->contains($groupUser)) {
  85. $this->groupUsers->removeElement($groupUser);
  86. }
  87. return $this;
  88. }
  89. public function getDateStart(): ?\DateTimeInterface
  90. {
  91. return $this->dateStart;
  92. }
  93. public function setDateStart(?\DateTimeInterface $dateStart): self
  94. {
  95. $this->dateStart = $dateStart;
  96. return $this;
  97. }
  98. public function getDateEnd(): ?\DateTimeInterface
  99. {
  100. return $this->dateEnd;
  101. }
  102. public function setDateEnd(?\DateTimeInterface $dateEnd): self
  103. {
  104. $this->dateEnd = $dateEnd;
  105. return $this;
  106. }
  107. public function getPermanent(): ?bool
  108. {
  109. return $this->permanent;
  110. }
  111. public function setPermanent(bool $permanent): self
  112. {
  113. $this->permanent = $permanent;
  114. return $this;
  115. }
  116. }