Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

169 rindas
3.9KB

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