Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

211 rindas
4.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\ReductionInterface;
  8. use Lc\CaracoleBundle\Doctrine\Extension\ReductionTrait;
  9. use Lc\CaracoleBundle\Model\Config\UnitModel;
  10. use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
  11. use Lc\SovBundle\Doctrine\Extension\StatusInterface;
  12. use Lc\SovBundle\Doctrine\Extension\StatusTrait;
  13. use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity;
  14. use Lc\SovBundle\Model\User\UserInterface;
  15. /**
  16. * @ORM\MappedSuperclass()
  17. */
  18. abstract class ReductionCreditModel extends AbstractLightEntity implements ReductionInterface,
  19. FilterMerchantInterface,
  20. StatusInterface, ReductionCreditInterface
  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\Merchant\MerchantInterface")
  36. * @ORM\JoinColumn(nullable=false)
  37. */
  38. protected $merchant;
  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. /**
  52. * @ORM\Column(type="datetime", nullable=true)
  53. */
  54. protected $activationDate;
  55. /**
  56. * @ORM\Column(type="string", length=255, nullable=true)
  57. */
  58. protected $ownerName;
  59. /**
  60. * @ORM\Column(type="text", nullable=true)
  61. */
  62. protected $ownerMessage;
  63. public function __construct()
  64. {
  65. $this->users = new ArrayCollection();
  66. $this->unit = UnitModel::UNIT_AMOUNT;
  67. }
  68. public function __toString()
  69. {
  70. return $this->title;
  71. }
  72. public function getTitle(): ?string
  73. {
  74. return $this->title;
  75. }
  76. public function setTitle(string $title): self
  77. {
  78. $this->title = $title;
  79. return $this;
  80. }
  81. public function getMerchant(): MerchantInterface
  82. {
  83. return $this->merchant;
  84. }
  85. public function setMerchant(MerchantInterface $merchant): self
  86. {
  87. $this->merchant = $merchant;
  88. return $this;
  89. }
  90. public function getType(): ?string
  91. {
  92. return $this->type;
  93. }
  94. public function setType(string $type): self
  95. {
  96. $this->type = $type;
  97. return $this;
  98. }
  99. /**
  100. * @return Collection|UserInterface[]
  101. */
  102. public function getUsers(): Collection
  103. {
  104. return $this->users;
  105. }
  106. public function addUser(UserInterface $user): self
  107. {
  108. if (!$this->users->contains($user)) {
  109. $this->users[] = $user;
  110. }
  111. return $this;
  112. }
  113. public function removeUser(UserInterface $user): self
  114. {
  115. if ($this->users->contains($user)) {
  116. $this->users->removeElement($user);
  117. }
  118. return $this;
  119. }
  120. public function getSended(): ?bool
  121. {
  122. return $this->sended;
  123. }
  124. public function setSended(?bool $sended): self
  125. {
  126. $this->sended = $sended;
  127. return $this;
  128. }
  129. public function getOwner(): ?UserInterface
  130. {
  131. return $this->owner;
  132. }
  133. public function setOwner(?UserInterface $owner): self
  134. {
  135. $this->owner = $owner;
  136. return $this;
  137. }
  138. public function getActivationDate(): ?\DateTimeInterface
  139. {
  140. return $this->activationDate;
  141. }
  142. public function setActivationDate(?\DateTimeInterface $activationDate): self
  143. {
  144. $this->activationDate = $activationDate;
  145. return $this;
  146. }
  147. public function getOwnerName(): ?string
  148. {
  149. return $this->ownerName;
  150. }
  151. public function setOwnerName(?string $ownerName): self
  152. {
  153. $this->ownerName = $ownerName;
  154. return $this;
  155. }
  156. public function getOwnerMessage(): ?string
  157. {
  158. return $this->ownerMessage;
  159. }
  160. public function setOwnerMessage(?string $ownerMessage): self
  161. {
  162. $this->ownerMessage = $ownerMessage;
  163. return $this;
  164. }
  165. }