src/Entity/Website/Order/OrderStatus.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Website\Order;
  3. use App\Entity\BaseEntity;
  4. use App\Repository\Website\Order\OrderStatusRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
  9. #[ORM\Entity(repositoryClassOrderStatusRepository::class)]
  10. class OrderStatus extends BaseEntity
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\Column(type'guid'uniquetrue)]
  14.     #[ORM\GeneratedValue(strategy'CUSTOM')]
  15.     #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
  16.     private ?string $id;
  17.     #[ORM\Column(length255)]
  18.     private ?string $name null;
  19.     #[ORM\OneToMany(mappedBy'status'targetEntityOrder::class)]
  20.     private Collection $orders;
  21.     #[ORM\Column(length255)]
  22.     private ?string $code null;
  23.     public function __construct()
  24.     {
  25.         parent::__construct();
  26.         $this->orders = new ArrayCollection();
  27.     }
  28.     public function __toString()
  29.     {
  30.         return $this->getName();
  31.     }
  32.     public function getId(): ?string
  33.     {
  34.         return $this->id;
  35.     }
  36.     public function getName(): ?string
  37.     {
  38.         return $this->name;
  39.     }
  40.     public function setName(string $name): static
  41.     {
  42.         $this->name $name;
  43.         return $this;
  44.     }
  45.     /**
  46.      * @return Collection<int, Order>
  47.      */
  48.     public function getOrders(): Collection
  49.     {
  50.         return $this->orders;
  51.     }
  52.     public function addOrder(Order $order): static
  53.     {
  54.         if (!$this->orders->contains($order)) {
  55.             $this->orders->add($order);
  56.             $order->setStatus($this);
  57.         }
  58.         return $this;
  59.     }
  60.     public function removeOrder(Order $order): static
  61.     {
  62.         if ($this->orders->removeElement($order)) {
  63.             // set the owning side to null (unless already changed)
  64.             if ($order->getStatus() === $this) {
  65.                 $order->setStatus(null);
  66.             }
  67.         }
  68.         return $this;
  69.     }
  70.     public function getCode(): ?string
  71.     {
  72.         return $this->code;
  73.     }
  74.     public function setCode(string $code): static
  75.     {
  76.         $this->code $code;
  77.         return $this;
  78.     }
  79. }