|
- <?php
-
- namespace Lc\CaracoleBundle\Model\Merchant;
-
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- use Lc\CaracoleBundle\Model\Address\AddressInterface;
- use Lc\CaracoleBundle\Model\Config\TaxRateInterface;
- use Lc\CaracoleBundle\Model\Section\SectionInterface;
- use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface;
- use Lc\CaracoleBundle\Model\Setting\MerchantSettingInterface;
- use Lc\SovBundle\Model\User\GroupUserInterface;
- use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;
-
- /**
- * @ORM\MappedSuperclass()
- */
- abstract class MerchantModel extends AbstractFullEntity
- {
-
- /**
- * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Config\TaxRateInterface")
- * @ORM\JoinColumn(nullable=false)
- */
- protected $taxRate;
-
- /**
- * @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\PointSale\PointSaleInterface", mappedBy="merchants")
- */
- protected $pointSales;
-
- /**
- * @ORM\OneToOne(targetEntity="Lc\CaracoleBundle\Model\Address\AddressInterface", inversedBy="merchant", cascade={"persist", "remove"})
- * @ORM\JoinColumn(nullable=true)
- */
- protected $address;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\User\GroupUserInterface", mappedBy="merchant")
- */
- protected $groupUsers;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Setting\MerchantSettingInterface", mappedBy="merchant", orphanRemoval=true, cascade={"persist"}, fetch="EAGER")
- */
- protected $settings;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface", mappedBy="merchant")
- */
- protected $sections;
-
- public function __construct()
- {
- $this->pointSales = new ArrayCollection();
- $this->groupUsers = new ArrayCollection();
- $this->settings = new ArrayCollection();
- }
-
- public function __toString()
- {
- return $this->getTitle() ;
- }
-
- public function getTaxRate(): ?TaxRateInterface
- {
- return $this->taxRate;
- }
-
- public function setTaxRate(?TaxRateInterface $taxRate): self
- {
- $this->taxRate = $taxRate;
-
- return $this;
- }
-
- /**
- * @return Collection|PointSaleInterface[]
- */
- public function getPointSales(): Collection
- {
- return $this->pointSales;
- }
-
- public function addPointSale(PointSaleInterface $pointSale): self
- {
- if (!$this->pointSales->contains($pointSale)) {
- $this->pointSales[] = $pointSale;
- $pointSale->addMerchant($this);
- }
-
- return $this;
- }
-
- public function removePointSale(PointSaleInterface $pointSale): self
- {
- if ($this->pointSales->contains($pointSale)) {
- $this->pointSales->removeElement($pointSale);
- $pointSale->removeMerchant($this);
- }
-
- return $this;
- }
-
- /**
- * @return Collection|MerchantSettingInterface[]
- */
- public function getSettings(): ?Collection
- {
- return $this->settings;
- }
-
- public function addSetting(MerchantSettingInterface $merchantSetting): self
- {
- if (!$this->settings->contains($merchantSetting)) {
- $this->settings[] = $merchantSetting;
- $merchantSetting->setMerchant($this);
- }
-
- return $this;
- }
-
- public function removeSetting(MerchantSettingInterface $merchantSetting): self
- {
- if ($this->settings->contains($merchantSetting)) {
- $this->settings->removeElement($merchantSetting);
- // set the owning side to null (unless already changed)
- if ($merchantSetting->getMerchant() === $this) {
- $merchantSetting->setMerchant(null);
- }
- }
-
- return $this;
- }
-
- public function getAddress(): ?AddressInterface
- {
- return $this->address;
- }
-
- public function setAddress(AddressInterface $address): self
- {
- $this->address = $address;
-
- return $this;
- }
-
- /**
- * @return Collection|GroupUserInterface[]
- */
- public function getGroupUsers(): Collection
- {
- return $this->groupUsers;
- }
-
- public function addGroupUser(GroupUserInterface $groupUser): self
- {
- if (!$this->groupUsers->contains($groupUser)) {
- $this->groupUsers[] = $groupUser;
- $groupUser->setMerchant($this);
- }
-
- return $this;
- }
-
- public function removeGroupUser(GroupUserInterface $groupUser): self
- {
- if ($this->groupUsers->contains($groupUser)) {
- $this->groupUsers->removeElement($groupUser);
- // set the owning side to null (unless already changed)
- if ($groupUser->getMerchant() === $this) {
- $groupUser->setMerchant(null);
- }
- }
-
- return $this;
- }
-
- /**
- * @return Collection|SectionInterface[]
- */
- public function getSections(): ?Collection
- {
- return $this->sections;
- }
-
- public function addSection(SectionInterface $section): self
- {
- if (!$this->sections->contains($section)) {
- $this->sections[] = $section;
- $section->setMerchant($this);
- }
-
- return $this;
- }
-
- public function removeSection(SectionInterface $section): self
- {
- if ($this->sections->contains($section)) {
- $this->sections->removeElement($section);
- // set the owning side to null (unless already changed)
- if ($section->getMerchant() === $this) {
- $section->setMerchant(null);
- }
- }
-
- return $this;
- }
- }
|