Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

159 linhas
3.4KB

  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")
  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. /**
  72. * @return Collection|User[]
  73. */
  74. public function getUsers(): Collection
  75. {
  76. return $this->users;
  77. }
  78. public function addUser(User $user): self
  79. {
  80. if (!$this->users->contains($user)) {
  81. $this->users[] = $user;
  82. }
  83. return $this;
  84. }
  85. public function removeUser(User $user): self
  86. {
  87. if ($this->users->contains($user)) {
  88. $this->users->removeElement($user);
  89. }
  90. return $this;
  91. }
  92. public function getType(): ?string
  93. {
  94. return $this->type;
  95. }
  96. public function setType(string $type): self
  97. {
  98. $this->type = $type;
  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. }