src/Entity/Promotion.php line 15

  1. <?php
  2. namespace App\Entity;
  3. use App\Kimia;
  4. use App\Repository\PromotionRepository;
  5. use App\Trait\ActivableTrait;
  6. use App\Trait\DateTrait;
  7. use DateTimeImmutable;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\ORM\Mapping as ORM;
  11. #[ORM\Entity(repositoryClassPromotionRepository::class)]
  12. class Promotion
  13. {
  14.     use DateTrait;
  15.     use ActivableTrait;
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue]
  18.     #[ORM\Column]
  19.     private ?int $id null;
  20.     #[ORM\Column(length255)]
  21.     private ?string $name null;
  22.     #[ORM\ManyToOne(cascade: ['persist'])]
  23.     private ?Attachment $thumbnail null;
  24.     #[ORM\Column]
  25.     private ?float $margin null;
  26.     #[ORM\Column(nullabletrue)]
  27.     private ?int $nbrLimit null;
  28.     #[ORM\ManyToOne(inversedBy'promotions')]
  29.     #[ORM\JoinColumn(nullablefalse)]
  30.     private ?Establishment $establishment null;
  31.     #[ORM\ManyToOne(inversedBy'promotions')]
  32.     #[ORM\JoinColumn(nullablefalse)]
  33.     private ?ArticleDepartment $article null;
  34.     #[ORM\Column]
  35.     private ?bool $isPromote null;
  36.     #[ORM\OneToMany(mappedBy'promotion'targetEntityOrder::class)]
  37.     private Collection $orders;
  38.     #[ORM\Column(length255)]
  39.     private ?string $code null;
  40.     public function __construct()
  41.     {
  42.         $this->isActive Kimia::ACTIVE;
  43.         if (is_null($this->createdAt)) $this->createdAt = new DateTimeImmutable();
  44.         $this->updatedAt = new DateTimeImmutable();
  45.         $this->orders = new ArrayCollection();
  46.     }
  47.     public function getId(): ?int
  48.     {
  49.         return $this->id;
  50.     }
  51.     public function getName(): ?string
  52.     {
  53.         return $this->name;
  54.     }
  55.     public function setName(string $name): self
  56.     {
  57.         $this->name $name;
  58.         return $this;
  59.     }
  60.     public function getThumbnail(): ?Attachment
  61.     {
  62.         return $this->thumbnail;
  63.     }
  64.     public function setThumbnail(?Attachment $thumbnail): self
  65.     {
  66.         $this->thumbnail $thumbnail;
  67.         return $this;
  68.     }
  69.     public function getNbrLimit(): ?int
  70.     {
  71.         return $this->nbrLimit;
  72.     }
  73.     public function setNbrLimit(?int $nbrLimit): self
  74.     {
  75.         $this->nbrLimit $nbrLimit;
  76.         return $this;
  77.     }
  78.     public function getEstablishment(): ?Establishment
  79.     {
  80.         return $this->establishment;
  81.     }
  82.     public function setEstablishment(?Establishment $establishment): self
  83.     {
  84.         $this->establishment $establishment;
  85.         return $this;
  86.     }
  87.     public function getArticle(): ?ArticleDepartment
  88.     {
  89.         return $this->article;
  90.     }
  91.     public function setArticle(?ArticleDepartment $article): self
  92.     {
  93.         $this->article $article;
  94.         return $this;
  95.     }
  96.     public function isIsPromote(): ?bool
  97.     {
  98.         return $this->isPromote;
  99.     }
  100.     public function setIsPromote(bool $isPromote): self
  101.     {
  102.         $this->isPromote $isPromote;
  103.         return $this;
  104.     }
  105.     public function getMargin(): ?float
  106.     {
  107.         return $this->margin;
  108.     }
  109.     public function setMargin(float $margin): self
  110.     {
  111.         $this->margin $margin;
  112.         return $this;
  113.     }
  114.     /**
  115.      * @return Collection<int, Order>
  116.      */
  117.     public function getOrders(): Collection
  118.     {
  119.         return $this->orders;
  120.     }
  121.     public function addOrder(Order $order): self
  122.     {
  123.         if (!$this->orders->contains($order)) {
  124.             $this->orders->add($order);
  125.             $order->setPromotion($this);
  126.         }
  127.         return $this;
  128.     }
  129.     public function removeOrder(Order $order): self
  130.     {
  131.         if ($this->orders->removeElement($order)) {
  132.             // set the owning side to null (unless already changed)
  133.             if ($order->getPromotion() === $this) {
  134.                 $order->setPromotion(null);
  135.             }
  136.         }
  137.         return $this;
  138.     }
  139.     public function getCode(): ?string
  140.     {
  141.         return $this->code;
  142.     }
  143.     public function setCode(string $code): self
  144.     {
  145.         $this->code $code;
  146.         return $this;
  147.     }
  148. }