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ů.

ReductionCreditModel.php 4.5KB

před 3 roky
před 3 roky
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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\Config\UnitModel;
  11. use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
  12. use Lc\CaracoleBundle\Model\Section\SectionInterface;
  13. use Lc\SovBundle\Doctrine\Extension\StatusInterface;
  14. use Lc\SovBundle\Doctrine\Extension\StatusTrait;
  15. use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity;
  16. use Lc\SovBundle\Model\User\UserInterface;
  17. /**
  18. * @ORM\MappedSuperclass()
  19. */
  20. abstract class ReductionCreditModel extends AbstractLightEntity implements ReductionInterface, FilterSectionInterface,
  21. StatusInterface
  22. {
  23. const TYPE_CREDIT = 'credit';
  24. const TYPE_GIFT = 'gift';
  25. use ReductionTrait;
  26. use StatusTrait;
  27. /**
  28. * @ORM\Column(type="string", length=255)
  29. */
  30. protected $title;
  31. /**
  32. * @ORM\ManyToMany(targetEntity="Lc\SovBundle\Model\User\UserInterface", inversedBy="reductionCredits")
  33. */
  34. protected $users;
  35. /**
  36. * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface")
  37. * @ORM\JoinColumn(nullable=false)
  38. */
  39. protected $section;
  40. /**
  41. * @ORM\Column(type="string", length=255)
  42. */
  43. protected $type;
  44. /**
  45. * @ORM\Column(type="boolean", nullable=true)
  46. */
  47. protected $sended;
  48. /**
  49. * @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface")
  50. */
  51. protected $owner;
  52. /**
  53. * @ORM\Column(type="datetime", nullable=true)
  54. */
  55. protected $activationDate;
  56. /**
  57. * @ORM\Column(type="string", length=255, nullable=true)
  58. */
  59. protected $ownerName;
  60. /**
  61. * @ORM\Column(type="text", nullable=true)
  62. */
  63. protected $ownerMessage;
  64. public function __construct()
  65. {
  66. $this->users = new ArrayCollection();
  67. $this->unit = UnitModel::UNIT_AMOUNT;
  68. }
  69. public function __toString()
  70. {
  71. return $this->title;
  72. }
  73. public function getTitle(): ?string
  74. {
  75. return $this->title;
  76. }
  77. public function setTitle(string $title): self
  78. {
  79. $this->title = $title;
  80. return $this;
  81. }
  82. public function getSection(): SectionInterface
  83. {
  84. return $this->section;
  85. }
  86. public function setSection(SectionInterface $section): self
  87. {
  88. $this->section = $section;
  89. return $this;
  90. }
  91. public function getType(): ?string
  92. {
  93. return $this->type;
  94. }
  95. public function setType(string $type): self
  96. {
  97. $this->type = $type;
  98. return $this;
  99. }
  100. /**
  101. * @return Collection|UserInterface[]
  102. */
  103. public function getUsers(): Collection
  104. {
  105. return $this->users;
  106. }
  107. public function addUser(UserInterface $user): self
  108. {
  109. if (!$this->users->contains($user)) {
  110. $this->users[] = $user;
  111. }
  112. return $this;
  113. }
  114. public function removeUser(UserInterface $user): self
  115. {
  116. if ($this->users->contains($user)) {
  117. $this->users->removeElement($user);
  118. }
  119. return $this;
  120. }
  121. public function getSended(): ?bool
  122. {
  123. return $this->sended;
  124. }
  125. public function setSended(?bool $sended): self
  126. {
  127. $this->sended = $sended;
  128. return $this;
  129. }
  130. public function getOwner(): ?UserInterface
  131. {
  132. return $this->owner;
  133. }
  134. public function setOwner(?UserInterface $owner): self
  135. {
  136. $this->owner = $owner;
  137. return $this;
  138. }
  139. public function getActivationDate(): ?\DateTimeInterface
  140. {
  141. return $this->activationDate;
  142. }
  143. public function setActivationDate(?\DateTimeInterface $activationDate): self
  144. {
  145. $this->activationDate = $activationDate;
  146. return $this;
  147. }
  148. public function getOwnerName(): ?string
  149. {
  150. return $this->ownerName;
  151. }
  152. public function setOwnerName(?string $ownerName): self
  153. {
  154. $this->ownerName = $ownerName;
  155. return $this;
  156. }
  157. public function getOwnerMessage(): ?string
  158. {
  159. return $this->ownerMessage;
  160. }
  161. public function setOwnerMessage(?string $ownerMessage): self
  162. {
  163. $this->ownerMessage = $ownerMessage;
  164. return $this;
  165. }
  166. }