Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

UserMerchant.php 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. /**
  9. * @ORM\MappedSuperclass()
  10. *
  11. */
  12. abstract class UserMerchant
  13. {
  14. /**
  15. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface", inversedBy="userMerchants")
  16. * @ORM\JoinColumn(nullable=false)
  17. */
  18. protected $user;
  19. /**
  20. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface")
  21. * @ORM\JoinColumn(nullable=false)
  22. */
  23. protected $merchant;
  24. /**
  25. * @ORM\Column(type="float")
  26. */
  27. protected $credit ;
  28. /**
  29. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\CreditHistoryInterface", mappedBy="userMerchant", orphanRemoval=true)
  30. */
  31. protected $creditHistories;
  32. public function __construct()
  33. {
  34. $this->creditHistories = new ArrayCollection();
  35. }
  36. public function getUser(): ?User
  37. {
  38. return $this->user;
  39. }
  40. public function setUser(?User $user): self
  41. {
  42. $this->user = $user;
  43. return $this;
  44. }
  45. public function getMerchant(): ?Hub
  46. {
  47. return $this->merchant;
  48. }
  49. public function setMerchant(?Hub $merchant): self
  50. {
  51. $this->merchant = $merchant;
  52. return $this;
  53. }
  54. public function getCredit(): ?float
  55. {
  56. return $this->credit;
  57. }
  58. public function setCredit(float $credit): self
  59. {
  60. $this->credit = $credit;
  61. return $this;
  62. }
  63. /**
  64. * @return Collection|CreditHistory[]
  65. */
  66. public function getCreditHistories(): Collection
  67. {
  68. return $this->creditHistories;
  69. }
  70. public function addCreditHistory(CreditHistoryInterface $creditHistory): self
  71. {
  72. if (!$this->creditHistories->contains($creditHistory)) {
  73. $this->creditHistories[] = $creditHistory;
  74. $creditHistory->setUserMerchant($this);
  75. }
  76. return $this;
  77. }
  78. public function removeCreditHistory(CreditHistoryInterface $creditHistory): self
  79. {
  80. if ($this->creditHistories->contains($creditHistory)) {
  81. $this->creditHistories->removeElement($creditHistory);
  82. // set the owning side to null (unless already changed)
  83. if ($creditHistory->getUserMerchant() === $this) {
  84. $creditHistory->setUserMerchant(null);
  85. }
  86. }
  87. return $this;
  88. }
  89. }