src/Entity/Shop/Order/Coupon.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Shop\Order;
  3. use App\Entity\BaseEntity;
  4. use App\Entity\Shop\Shop\Shop;
  5. use App\Repository\Shop\Order\CouponRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\DBAL\Types\Types;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
  11. #[ORM\Entity(repositoryClassCouponRepository::class)]
  12. class Coupon extends BaseEntity
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\Column(type'guid'uniquetrue)]
  16.     #[ORM\GeneratedValue(strategy'CUSTOM')]
  17.     #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
  18.     private ?string $id;
  19.     #[ORM\Column(length255)]
  20.     private ?string $code null;
  21.     #[ORM\Column(nullabletrue)]
  22.     private ?float $percentage null;
  23.     #[ORM\Column(typeTypes::BIGINTnullabletrue)]
  24.     private ?string $fixedAmount null;
  25.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  26.     private ?\DateTimeInterface $startDate null;
  27.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  28.     private ?\DateTimeInterface $endDate null;
  29.     #[ORM\Column]
  30.     private ?int $maxUses null;
  31.     #[ORM\Column]
  32.     private ?int $usedCount null;
  33.     #[ORM\ManyToOne(inversedBy'coupons')]
  34.     #[ORM\JoinColumn(nullablefalse)]
  35.     private ?Shop $shop null;
  36.     #[ORM\OneToMany(mappedBy'coupon'targetEntityOrder::class)]
  37.     private Collection $orders;
  38.     #[ORM\Column(length255)]
  39.     private ?string $title null;
  40.     public function __construct()
  41.     {
  42.         parent::__construct();
  43.         $this->orders = new ArrayCollection();
  44.         $this->setMaxUses(1000000);
  45.         $this->setUsedCount(0);
  46.     }
  47.     public function getId(): ?string
  48.     {
  49.         return $this->id;
  50.     }
  51.     public function getCode(): ?string
  52.     {
  53.         return $this->code;
  54.     }
  55.     public function setCode(string $code): static
  56.     {
  57.         $this->code $code;
  58.         return $this;
  59.     }
  60.     public function getPercentage(): ?float
  61.     {
  62.         return $this->percentage;
  63.     }
  64.     public function setPercentage(float $percentage): static
  65.     {
  66.         $this->percentage $percentage;
  67.         return $this;
  68.     }
  69.     public function getFixedAmount(): ?string
  70.     {
  71.         return $this->fixedAmount;
  72.     }
  73.     public function setFixedAmount(?string $fixedAmount): static
  74.     {
  75.         $this->fixedAmount $fixedAmount;
  76.         return $this;
  77.     }
  78.     public function getStartDate(): ?\DateTimeInterface
  79.     {
  80.         return $this->startDate;
  81.     }
  82.     public function setStartDate(?\DateTimeInterface $startDate): static
  83.     {
  84.         $this->startDate $startDate;
  85.         return $this;
  86.     }
  87.     public function getEndDate(): ?\DateTimeInterface
  88.     {
  89.         return $this->endDate;
  90.     }
  91.     public function setEndDate(?\DateTimeInterface $endDate): static
  92.     {
  93.         $this->endDate $endDate;
  94.         return $this;
  95.     }
  96.     public function getMaxUses(): ?int
  97.     {
  98.         return $this->maxUses;
  99.     }
  100.     public function setMaxUses(int $maxUses): static
  101.     {
  102.         $this->maxUses $maxUses;
  103.         return $this;
  104.     }
  105.     public function getUsedCount(): ?int
  106.     {
  107.         return $this->usedCount;
  108.     }
  109.     public function setUsedCount(int $usedCount): static
  110.     {
  111.         $this->usedCount $usedCount;
  112.         return $this;
  113.     }
  114.     public function getShop(): ?Shop
  115.     {
  116.         return $this->shop;
  117.     }
  118.     public function setShop(?Shop $shop): static
  119.     {
  120.         $this->shop $shop;
  121.         return $this;
  122.     }
  123.     /**
  124.      * @return Collection<int, Order>
  125.      */
  126.     public function getOrders(): Collection
  127.     {
  128.         return $this->orders;
  129.     }
  130.     public function addOrder(Order $order): static
  131.     {
  132.         if (!$this->orders->contains($order)) {
  133.             $this->orders->add($order);
  134.             $order->setCoupon($this);
  135.         }
  136.         return $this;
  137.     }
  138.     public function removeOrder(Order $order): static
  139.     {
  140.         if ($this->orders->removeElement($order)) {
  141.             // set the owning side to null (unless already changed)
  142.             if ($order->getCoupon() === $this) {
  143.                 $order->setCoupon(null);
  144.             }
  145.         }
  146.         return $this;
  147.     }
  148.     public function getTitle(): ?string
  149.     {
  150.         return $this->title;
  151.     }
  152.     public function setTitle(string $title): static
  153.     {
  154.         $this->title $title;
  155.         return $this;
  156.     }
  157. }