100 line
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. }
  34. public function __toString()
  35. {
  36. return $this->title;
  37. }
  38. public function getTitle(): ?string
  39. {
  40. return $this->title;
  41. }
  42. public function setTitle(string $title): self
  43. {
  44. $this->title = $title;
  45. return $this;
  46. }
  47. public function getMerchant(): ?Merchant
  48. {
  49. return $this->merchant;
  50. }
  51. public function setMerchant(?Merchant $merchant): self
  52. {
  53. $this->merchant = $merchant;
  54. return $this;
  55. }
  56. /**
  57. * @return Collection|User[]
  58. */
  59. public function getUsers(): Collection
  60. {
  61. return $this->users;
  62. }
  63. public function addUser(User $user): self
  64. {
  65. if (!$this->users->contains($user)) {
  66. $this->users[] = $user;
  67. }
  68. return $this;
  69. }
  70. public function removeUser(User $user): self
  71. {
  72. if ($this->users->contains($user)) {
  73. $this->users->removeElement($user);
  74. }
  75. return $this;
  76. }
  77. }