преди 4 години
преди 4 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. }