Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

4 лет назад
4 лет назад
4 лет назад
4 лет назад
4 лет назад
4 лет назад
4 лет назад
4 лет назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. public function __construct()
  38. {
  39. $this->creditHistories = new ArrayCollection();
  40. }
  41. public function getUser(): ?User
  42. {
  43. return $this->user;
  44. }
  45. public function setUser(?User $user): self
  46. {
  47. $this->user = $user;
  48. return $this;
  49. }
  50. public function getMerchant(): ?Merchant
  51. {
  52. return $this->merchant;
  53. }
  54. public function setMerchant(?Merchant $merchant): self
  55. {
  56. $this->merchant = $merchant;
  57. return $this;
  58. }
  59. public function getCredit(): ?float
  60. {
  61. return $this->credit;
  62. }
  63. public function setCredit(?float $credit): self
  64. {
  65. $this->credit = $credit;
  66. return $this;
  67. }
  68. public function getCreditActive(): ?bool
  69. {
  70. return $this->creditActive;
  71. }
  72. public function isCreditActive(): bool
  73. {
  74. return $this->creditActive;
  75. }
  76. public function setCreditActive(bool $creditActive): self
  77. {
  78. $this->creditActive = $creditActive;
  79. return $this;
  80. }
  81. /**
  82. * @return Collection|CreditHistory[]
  83. */
  84. public function getCreditHistories(): Collection
  85. {
  86. return $this->creditHistories;
  87. }
  88. public function addCreditHistory(CreditHistoryInterface $creditHistory): self
  89. {
  90. if (!$this->creditHistories->contains($creditHistory)) {
  91. $this->creditHistories[] = $creditHistory;
  92. $creditHistory->setUserMerchant($this);
  93. }
  94. return $this;
  95. }
  96. public function removeCreditHistory(CreditHistoryInterface $creditHistory): self
  97. {
  98. if ($this->creditHistories->contains($creditHistory)) {
  99. $this->creditHistories->removeElement($creditHistory);
  100. // set the owning side to null (unless already changed)
  101. if ($creditHistory->getUserMerchant() === $this) {
  102. $creditHistory->setUserMerchant(null);
  103. }
  104. }
  105. return $this;
  106. }
  107. }