Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

102 lines
2.3KB

  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. use ReductionTrait;
  16. use StatusTrait;
  17. /**
  18. * @ORM\Column(type="string", length=255)
  19. */
  20. protected $title;
  21. /**
  22. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\UserInterface")
  23. */
  24. protected $users;
  25. /**
  26. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface")
  27. * @ORM\JoinColumn(nullable=false)
  28. */
  29. protected $merchant;
  30. public function __construct()
  31. {
  32. $this->users = new ArrayCollection();
  33. $this->unit = 'amount';
  34. }
  35. public function __toString()
  36. {
  37. return $this->title;
  38. }
  39. public function getTitle(): ?string
  40. {
  41. return $this->title;
  42. }
  43. public function setTitle(string $title): self
  44. {
  45. $this->title = $title;
  46. return $this;
  47. }
  48. public function getMerchant(): ?Merchant
  49. {
  50. return $this->merchant;
  51. }
  52. public function setMerchant(?Merchant $merchant): self
  53. {
  54. $this->merchant = $merchant;
  55. return $this;
  56. }
  57. /**
  58. * @return Collection|User[]
  59. */
  60. public function getUsers(): Collection
  61. {
  62. return $this->users;
  63. }
  64. public function addUser(User $user): self
  65. {
  66. if (!$this->users->contains($user)) {
  67. $this->users[] = $user;
  68. }
  69. return $this;
  70. }
  71. public function removeUser(User $user): self
  72. {
  73. if ($this->users->contains($user)) {
  74. $this->users->removeElement($user);
  75. }
  76. return $this;
  77. }
  78. }