src/Entity/OrderType.php line 13

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\OrderTypeRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Gedmo\Timestampable\Traits\TimestampableEntity;
  9. #[ORM\Entity(repositoryClassOrderTypeRepository::class)]
  10. class OrderType
  11. {
  12.     use TimestampableEntity;
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\Column(length255)]
  18.     private ?string $name null;
  19.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  20.     private ?string $description null;
  21.     #[ORM\OneToMany(mappedBy'orderType'targetEntityOrder::class)]
  22.     private Collection $orders;
  23.     #[ORM\OneToMany(mappedBy'orderType'targetEntityRuleCondition::class)]
  24.     private Collection $ruleConditions;
  25.     public function __construct()
  26.     {
  27.         $this->orders = new ArrayCollection();
  28.         $this->ruleConditions = new ArrayCollection();
  29.     }
  30.     public function getId(): ?int
  31.     {
  32.         return $this->id;
  33.     }
  34.     public function getName(): ?string
  35.     {
  36.         return $this->name;
  37.     }
  38.     public function setName(string $name): self
  39.     {
  40.         $this->name $name;
  41.         return $this;
  42.     }
  43.     public function getDescription(): ?string
  44.     {
  45.         return $this->description;
  46.     }
  47.     public function setDescription(?string $description): self
  48.     {
  49.         $this->description $description;
  50.         return $this;
  51.     }
  52.     /**
  53.      * @return Collection<int, Order>
  54.      */
  55.     public function getOrders(): Collection
  56.     {
  57.         return $this->orders;
  58.     }
  59.     public function addOrder(Order $order): self
  60.     {
  61.         if (!$this->orders->contains($order)) {
  62.             $this->orders->add($order);
  63.             $order->setOrderType($this);
  64.         }
  65.         return $this;
  66.     }
  67.     public function removeOrder(Order $order): self
  68.     {
  69.         if ($this->orders->removeElement($order)) {
  70.             // set the owning side to null (unless already changed)
  71.             if ($order->getOrderType() === $this) {
  72.                 $order->setOrderType(null);
  73.             }
  74.         }
  75.         return $this;
  76.     }
  77.     /**
  78.      * @return Collection<int, RuleCondition>
  79.      */
  80.     public function getRuleConditions(): Collection
  81.     {
  82.         return $this->ruleConditions;
  83.     }
  84.     public function addRuleCondition(RuleCondition $ruleCondition): static
  85.     {
  86.         if (!$this->ruleConditions->contains($ruleCondition)) {
  87.             $this->ruleConditions->add($ruleCondition);
  88.             $ruleCondition->setOrderType($this);
  89.         }
  90.         return $this;
  91.     }
  92.     public function removeRuleCondition(RuleCondition $ruleCondition): static
  93.     {
  94.         if ($this->ruleConditions->removeElement($ruleCondition)) {
  95.             // set the owning side to null (unless already changed)
  96.             if ($ruleCondition->getOrderType() === $this) {
  97.                 $ruleCondition->setOrderType(null);
  98.             }
  99.         }
  100.         return $this;
  101.     }
  102.     public function __toString(): string
  103.     {
  104.         return (string)$this->name;
  105.     }
  106. }