|
- <?php
-
- namespace Lc\CaracoleBundle\Model\PointSale;
-
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- use Lc\CaracoleBundle\Doctrine\Extension\FilterMultipleMerchantsInterface;
- use Lc\CaracoleBundle\Doctrine\Extension\OrderAmountMinTrait;
- use Lc\CaracoleBundle\Doctrine\Extension\OrderAmountMinInterface;
- use Lc\CaracoleBundle\Model\Address\AddressInterface;
- use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
- use Lc\CaracoleBundle\Model\User\UserPointSaleInterface;
- use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;
- use App\Entity\File\File;
-
- /**
- * @ORM\MappedSuperclass()
- */
- abstract class PointSaleModel extends AbstractFullEntity implements FilterMultipleMerchantsInterface,
- OrderAmountMinInterface, PointSaleInterface
- {
-
- use OrderAmountMinTrait;
-
- /**
- * @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", inversedBy="pointSales")
- */
- protected $merchants;
-
- /**
- * @ORM\Column(type="string", length=63, nullable=true)
- */
- protected $code;
-
- /**
- * @ORM\Column(type="float")
- */
- protected $deliveryPrice;
-
- /**
- * @ORM\Column(type="boolean")
- */
- protected $isPublic;
-
- /**
- * @ORM\OneToOne(targetEntity="Lc\CaracoleBundle\Model\Address\AddressInterface", inversedBy="pointSale", cascade={"persist", "remove"})
- * @ORM\JoinColumn(nullable=false)
- */
- protected $address;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\User\UserPointSaleInterface", mappedBy="pointSale", orphanRemoval=true)
- */
- protected $userPointSales;
-
- /**
- * @ORM\ManyToOne(targetEntity=File::class, cascade={"persist", "remove"})
- */
- protected $image;
-
- public function __construct()
- {
- $this->merchants = new ArrayCollection();
- $this->userPointSales = new ArrayCollection();
- }
-
- public function __toString()
- {
- return $this->getTitle();
- }
-
- /**
- * @return Collection|MerchantInterface[]
- */
- public function getMerchants(): Collection
- {
- return $this->merchants;
- }
-
- public function addMerchant(MerchantInterface $merchant): self
- {
- if (!$this->merchants->contains($merchant)) {
- $this->merchants[] = $merchant;
- }
-
- return $this;
- }
-
- public function removeMerchant(MerchantInterface $merchant): self
- {
- if ($this->merchants->contains($merchant)) {
- $this->merchants->removeElement($merchant);
- }
-
- return $this;
- }
-
- public function getCode(): ?string
- {
- return $this->code;
- }
-
- public function setCode(?string $code): self
- {
- $this->code = $code;
-
- return $this;
- }
-
-
- public function getDeliveryPrice(): ?float
- {
- return $this->deliveryPrice;
- }
-
- public function setDeliveryPrice(float $deliveryPrice): self
- {
- $this->deliveryPrice = $deliveryPrice;
-
- return $this;
- }
-
- public function getIsPublic(): ?bool
- {
- return $this->isPublic;
- }
-
- public function setIsPublic(bool $isPublic): self
- {
- $this->isPublic = $isPublic;
-
- return $this;
- }
-
- public function getAddress(): ?AddressInterface
- {
- return $this->address;
- }
-
- public function setAddress(AddressInterface $address): self
- {
- $this->address = $address;
-
- return $this;
- }
-
- /**
- * @return Collection|UserPointSaleInterface[]
- */
- public function getUserPointSales(): Collection
- {
- return $this->userPointSales;
- }
-
- public function addUserPointSale(UserPointSaleInterface $userPointSale): self
- {
- if (!$this->userPointSales->contains($userPointSale)) {
- $this->userPointSales[] = $userPointSale;
- $userPointSale->setPointSale($this);
- }
-
- return $this;
- }
-
- public function removeUserPointSale(UserPointSaleInterface $userPointSale): self
- {
- if ($this->userPointSales->contains($userPointSale)) {
- $this->userPointSales->removeElement($userPointSale);
- // set the owning side to null (unless already changed)
- if ($userPointSale->getPointSale() === $this) {
- $userPointSale->setPointSale(null);
- }
- }
-
- return $this;
- }
-
- public function getImage(): ?File
- {
- return $this->image;
- }
-
- public function setImage(?File $image): self
- {
- $this->image = $image;
-
- return $this;
- }
- }
|