Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

164 lines
3.4KB

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