src/IlaveU/ShopBundle/Entity/Promotion/Promotion.php line 19
<?phpnamespace App\IlaveU\ShopBundle\Entity\Promotion;use ApiPlatform\Core\Annotation\ApiResource;use App\IlaveU\ShopBundle\Entity\Product\CategoryProduct;use App\IlaveU\ShopBundle\Entity\Product\Product;use App\IlaveU\ShopBundle\Repository\Promotion\PromotionRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Validator\Constraints as Assert;use Gedmo\Mapping\Annotation as Gedmo;use Gedmo\Sortable\Entity\Repository\SortableRepository;#[ApiResource]#[ORM\Entity(repositoryClass: PromotionRepository::class)]#[ORM\Cache(usage:"NONSTRICT_READ_WRITE",region:"append_depend")]class Promotion implements \Stringable{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column(type: 'integer')]private $id;#[ORM\Column(type: 'float')]private ?float $value = 0;#[ORM\Column(type: 'string', length: 255, nullable: true)]private ?string $type = "price";#[ORM\Column(type: 'text', nullable: true)]private ?string $description = null;#[ORM\Column(type: 'string', length: 255)]private ?string $code = null;#[ORM\Column(type: 'string', length: 255)]#[Assert\NotNull()]private ?string $name = null;#[Gedmo\SortablePosition]#[ORM\Column(type: 'integer', nullable: true)]private ?int $priority = null;#[ORM\Column(type: 'integer', nullable: true)]private ?int $usageLimit = null;#[ORM\Column(type: 'datetime_immutable', nullable: true)]private ?\DateTimeImmutable $startAt = null;#[ORM\Column(type: 'datetime_immutable', nullable: true)]private ?\DateTimeImmutable $endAt = null;#[ORM\OneToMany(targetEntity: Coupon::class, mappedBy: 'promotion')]private \Doctrine\Common\Collections\Collection|array $coupons;#[ORM\OneToMany(targetEntity: PromotionRule::class, mappedBy: 'promotion', orphanRemoval: true)]private \Doctrine\Common\Collections\Collection|array $promotionRules;#[ORM\OneToMany(targetEntity: PromotionAction::class, mappedBy: 'promotion', orphanRemoval: true)]private \Doctrine\Common\Collections\Collection|array $promotionActions;#[ORM\OneToMany(targetEntity: Product::class, mappedBy: 'promotion')]private \Doctrine\Common\Collections\Collection|array $products;#[ORM\Column(nullable: true)]private ?bool $keepCurrentPrice = null;#[ORM\OneToMany(mappedBy: 'promotion', targetEntity: CategoryProduct::class)]private Collection $categories;#[ORM\Column(nullable: true)]private ?float $adjustableValue = 0;public function __toString(): string{return (string) $this->name;}public function __construct(){$this->coupons = new ArrayCollection();$this->promotionRules = new ArrayCollection();$this->promotionActions = new ArrayCollection();$this->products = new ArrayCollection();$this->categories = new ArrayCollection();}public function getId(): ?int{return $this->id;}public function getValue(): ?float{return $this->value;}public function setValue(float $value): self{$this->value = $value;return $this;}public function getType(): ?string{return $this->type;}public function setType(?string $type): self{$this->type = $type;return $this;}public function getDescription(): ?string{return $this->description;}public function setDescription(?string $description): self{$this->description = $description;return $this;}public function getCode(): ?string{return $this->code;}public function setCode(string $code): self{$this->code = $code;return $this;}public function getName(): ?string{return $this->name;}public function setName(string $name): self{$this->name = $name;return $this;}public function getPriority(): ?int{return $this->priority;}public function setPriority(?int $priority): self{$this->priority = $priority;return $this;}public function getUsageLimit(): ?int{return $this->usageLimit;}public function setUsageLimit(?int $usageLimit): self{$this->usageLimit = $usageLimit;return $this;}public function getStartAt(): ?\DateTimeImmutable{return $this->startAt;}public function setStartAt(?\DateTimeImmutable $startAt): self{$this->startAt = $startAt;return $this;}public function getEndAt(): ?\DateTimeImmutable{return $this->endAt;}public function setEndAt(?\DateTimeImmutable $endAt): self{$this->endAt = $endAt;return $this;}/*** @return Collection|Coupon[]*/public function getCoupons(): Collection{return $this->coupons;}public function addCoupon(Coupon $coupon): self{if (!$this->coupons->contains($coupon)) {$this->coupons[] = $coupon;$coupon->setPromotion($this);}return $this;}public function removeCoupon(Coupon $coupon): self{if ($this->coupons->removeElement($coupon)) {// set the owning side to null (unless already changed)if ($coupon->getPromotion() === $this) {$coupon->setPromotion(null);}}return $this;}/*** @return Collection|PromotionRule[]*/public function getPromotionRules(): Collection{return $this->promotionRules;}public function addPromotionRule(PromotionRule $promotionRule): self{if (!$this->promotionRules->contains($promotionRule)) {$this->promotionRules[] = $promotionRule;$promotionRule->setPromotion($this);}return $this;}public function removePromotionRule(PromotionRule $promotionRule): self{if ($this->promotionRules->removeElement($promotionRule)) {// set the owning side to null (unless already changed)if ($promotionRule->getPromotion() === $this) {$promotionRule->setPromotion(null);}}return $this;}/*** @return Collection|PromotionAction[]*/public function getPromotionActions(): Collection{return $this->promotionActions;}public function addPromotionAction(PromotionAction $promotionAction): self{if (!$this->promotionActions->contains($promotionAction)) {$this->promotionActions[] = $promotionAction;$promotionAction->setPromotion($this);}return $this;}public function removePromotionAction(PromotionAction $promotionAction): self{if ($this->promotionActions->removeElement($promotionAction)) {// set the owning side to null (unless already changed)if ($promotionAction->getPromotion() === $this) {$promotionAction->setPromotion(null);}}return $this;}/*** @return Collection|Product[]*/public function getProducts(): Collection{return $this->products;}public function addProduct(Product $product): self{if (!$this->products->contains($product)) {$this->products[] = $product;$product->setPromotion($this);}return $this;}public function removeProduct(Product $product): self{if ($this->products->removeElement($product)) {// set the owning side to null (unless already changed)if ($product->getPromotion() === $this) {$product->setPromotion(null);}}return $this;}public function isKeepCurrentPrice(): ?bool{return $this->keepCurrentPrice;}public function setKeepCurrentPrice(?bool $keepCurrentPrice): static{$this->keepCurrentPrice = $keepCurrentPrice;return $this;}/*** @return Collection<int, CategoryProduct>*/public function getCategories(): Collection{return $this->categories;}public function addCategory(CategoryProduct $category): static{if (!$this->categories->contains($category)) {$this->categories->add($category);$category->setPromotion($this);}return $this;}public function removeCategory(CategoryProduct $category): static{if ($this->categories->removeElement($category)) {// set the owning side to null (unless already changed)if ($category->getPromotion() === $this) {$category->setPromotion(null);}}return $this;}public function getAdjustableValue(): ?float{return (float)$this->adjustableValue;}public function setAdjustableValue(?float $adjustableValue): static{$this->adjustableValue = $adjustableValue;return $this;}}