|
- <?php
-
- namespace Lc\ShopBundle\Model;
-
- use App\Entity\CreditHistory;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- use Lc\ShopBundle\Context\CreditHistoryInterface;
-
- /**
- * @ORM\MappedSuperclass()
- *
- */
- abstract class UserMerchant
- {
- /**
- * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface", inversedBy="userMerchants")
- * @ORM\JoinColumn(nullable=false)
- */
- protected $user;
-
- /**
- * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface")
- * @ORM\JoinColumn(nullable=false)
- */
- protected $merchant;
-
- /**
- * @ORM\Column(type="float")
- */
- protected $credit ;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\CreditHistoryInterface", mappedBy="userMerchant", orphanRemoval=true)
- */
- protected $creditHistories;
-
- public function __construct()
- {
- $this->creditHistories = new ArrayCollection();
- }
-
- public function getUser(): ?User
- {
- return $this->user;
- }
-
- public function setUser(?User $user): self
- {
- $this->user = $user;
-
- return $this;
- }
-
- public function getMerchant(): ?Hub
- {
- return $this->merchant;
- }
-
- public function setMerchant(?Hub $merchant): self
- {
- $this->merchant = $merchant;
-
- return $this;
- }
-
- public function getCredit(): ?float
- {
- return $this->credit;
- }
-
- public function setCredit(float $credit): self
- {
- $this->credit = $credit;
-
- return $this;
- }
-
- /**
- * @return Collection|CreditHistory[]
- */
- public function getCreditHistories(): Collection
- {
- return $this->creditHistories;
- }
-
- public function addCreditHistory(CreditHistoryInterface $creditHistory): self
- {
- if (!$this->creditHistories->contains($creditHistory)) {
- $this->creditHistories[] = $creditHistory;
- $creditHistory->setUserMerchant($this);
- }
-
- return $this;
- }
-
- public function removeCreditHistory(CreditHistoryInterface $creditHistory): self
- {
- if ($this->creditHistories->contains($creditHistory)) {
- $this->creditHistories->removeElement($creditHistory);
- // set the owning side to null (unless already changed)
- if ($creditHistory->getUserMerchant() === $this) {
- $creditHistory->setUserMerchant(null);
- }
- }
-
- return $this;
- }
- }
|