You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

UserMerchant.php 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?php
  2. namespace Lc\ShopBundle\Model;
  3. use App\Entity\CreditHistory;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Lc\ShopBundle\Context\CreditHistoryInterface;
  8. use Lc\ShopBundle\Context\FilterMerchantInterface;
  9. /**
  10. * @ORM\MappedSuperclass()
  11. *
  12. */
  13. abstract class UserMerchant implements FilterMerchantInterface
  14. {
  15. /**
  16. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface", inversedBy="userMerchants")
  17. * @ORM\JoinColumn(nullable=false)
  18. */
  19. protected $user;
  20. /**
  21. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface")
  22. * @ORM\JoinColumn(nullable=false)
  23. */
  24. protected $merchant;
  25. /**
  26. * @ORM\Column(type="float", nullable=true)
  27. */
  28. protected $credit;
  29. /**
  30. * @ORM\Column(type="boolean")
  31. */
  32. protected $creditActive;
  33. /**
  34. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\CreditHistoryInterface", mappedBy="userMerchant", orphanRemoval=true)
  35. */
  36. protected $creditHistories;
  37. /**
  38. * @ORM\Column(type="boolean")
  39. */
  40. protected $active;
  41. public function __construct()
  42. {
  43. $this->creditHistories = new ArrayCollection();
  44. }
  45. public function getUser(): ?User
  46. {
  47. return $this->user;
  48. }
  49. public function setUser(?User $user): self
  50. {
  51. $this->user = $user;
  52. return $this;
  53. }
  54. public function getMerchant(): ?Merchant
  55. {
  56. return $this->merchant;
  57. }
  58. public function setMerchant(?Merchant $merchant): self
  59. {
  60. $this->merchant = $merchant;
  61. return $this;
  62. }
  63. public function getCredit(): ?float
  64. {
  65. return $this->credit;
  66. }
  67. public function setCredit(?float $credit): self
  68. {
  69. $this->credit = $credit;
  70. return $this;
  71. }
  72. public function getCreditActive(): ?bool
  73. {
  74. return $this->creditActive;
  75. }
  76. public function isCreditActive(): bool
  77. {
  78. return $this->creditActive;
  79. }
  80. public function setCreditActive(bool $creditActive): self
  81. {
  82. $this->creditActive = $creditActive;
  83. return $this;
  84. }
  85. /**
  86. * @return Collection|CreditHistory[]
  87. */
  88. public function getCreditHistories(): Collection
  89. {
  90. return $this->creditHistories;
  91. }
  92. public function addCreditHistory(CreditHistoryInterface $creditHistory): self
  93. {
  94. if (!$this->creditHistories->contains($creditHistory)) {
  95. $this->creditHistories[] = $creditHistory;
  96. $creditHistory->setUserMerchant($this);
  97. }
  98. return $this;
  99. }
  100. public function removeCreditHistory(CreditHistoryInterface $creditHistory): self
  101. {
  102. if ($this->creditHistories->contains($creditHistory)) {
  103. $this->creditHistories->removeElement($creditHistory);
  104. // set the owning side to null (unless already changed)
  105. if ($creditHistory->getUserMerchant() === $this) {
  106. $creditHistory->setUserMerchant(null);
  107. }
  108. }
  109. return $this;
  110. }
  111. public function getActive(): ?bool
  112. {
  113. return $this->active;
  114. }
  115. public function setActive(bool $active): self
  116. {
  117. $this->active = $active;
  118. return $this;
  119. }
  120. }