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.

165 lines
3.5KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Model\Reduction;
  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\FilterMerchantInterface;
  7. use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface;
  8. use Lc\CaracoleBundle\Doctrine\Extension\ReductionInterface;
  9. use Lc\CaracoleBundle\Doctrine\Extension\ReductionTrait;
  10. use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
  11. use Lc\CaracoleBundle\Model\Section\SectionInterface;
  12. use Lc\SovBundle\Doctrine\Extension\StatusInterface;
  13. use Lc\SovBundle\Doctrine\Extension\StatusTrait;
  14. use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity;
  15. use Lc\SovBundle\Model\User\UserInterface;
  16. /**
  17. * @ORM\MappedSuperclass()
  18. */
  19. abstract class ReductionCreditModel extends AbstractLightEntity implements ReductionInterface, FilterSectionInterface,
  20. StatusInterface
  21. {
  22. const TYPE_CREDIT = 'credit';
  23. const TYPE_GIFT = 'gift';
  24. use ReductionTrait;
  25. use StatusTrait;
  26. /**
  27. * @ORM\Column(type="string", length=255)
  28. */
  29. protected $title;
  30. /**
  31. * @ORM\ManyToMany(targetEntity="Lc\SovBundle\Model\User\UserInterface", inversedBy="reductionCredits")
  32. */
  33. protected $users;
  34. /**
  35. * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface")
  36. * @ORM\JoinColumn(nullable=false)
  37. */
  38. protected $section;
  39. /**
  40. * @ORM\Column(type="string", length=255)
  41. */
  42. protected $type;
  43. /**
  44. * @ORM\Column(type="boolean", nullable=true)
  45. */
  46. protected $sended;
  47. /**
  48. * @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface")
  49. */
  50. protected $owner;
  51. public function __construct()
  52. {
  53. $this->users = new ArrayCollection();
  54. $this->unit = 'amount';
  55. }
  56. public function __toString()
  57. {
  58. return $this->title;
  59. }
  60. public function getTitle(): ?string
  61. {
  62. return $this->title;
  63. }
  64. public function setTitle(string $title): self
  65. {
  66. $this->title = $title;
  67. return $this;
  68. }
  69. public function getSection(): SectionInterface
  70. {
  71. return $this->section;
  72. }
  73. public function setSection(SectionInterface $section): self
  74. {
  75. $this->section = $section;
  76. return $this;
  77. }
  78. public function getType(): ?string
  79. {
  80. return $this->type;
  81. }
  82. public function setType(string $type): self
  83. {
  84. $this->type = $type;
  85. return $this;
  86. }
  87. /**
  88. * @return Collection|UserInterface[]
  89. */
  90. public function getUsers(): Collection
  91. {
  92. return $this->users;
  93. }
  94. public function addUser(UserInterface $user): self
  95. {
  96. if (!$this->users->contains($user)) {
  97. $this->users[] = $user;
  98. }
  99. return $this;
  100. }
  101. public function removeUser(UserInterface $user): self
  102. {
  103. if ($this->users->contains($user)) {
  104. $this->users->removeElement($user);
  105. }
  106. return $this;
  107. }
  108. public function getSended(): ?bool
  109. {
  110. return $this->sended;
  111. }
  112. public function setSended(?bool $sended): self
  113. {
  114. $this->sended = $sended;
  115. return $this;
  116. }
  117. public function getOwner(): ?UserInterface
  118. {
  119. return $this->owner;
  120. }
  121. public function setOwner(?UserInterface $owner): self
  122. {
  123. $this->owner = $owner;
  124. return $this;
  125. }
  126. }