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.

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