src/Entity/Status.php line 11

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\StatusRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassStatusRepository::class)]
  8. class Status
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id null;
  14.     #[ORM\Column(length255)]
  15.     private ?string $status_name null;
  16.     #[ORM\OneToMany(mappedBy'order_status'targetEntityOrder::class)]
  17.     private Collection $orders;
  18.     public function __construct()
  19.     {
  20.         $this->orders = new ArrayCollection();
  21.     }
  22.     public function getId(): ?int
  23.     {
  24.         return $this->id;
  25.     }
  26.     public function getStatusName(): ?string
  27.     {
  28.         return $this->status_name;
  29.     }
  30.     public function setStatusName(string $status_name): self
  31.     {
  32.         $this->status_name $status_name;
  33.         return $this;
  34.     }
  35.     /**
  36.      * @return Collection<int, Order>
  37.      */
  38.     public function getOrders(): Collection
  39.     {
  40.         return $this->orders;
  41.     }
  42.     public function addOrder(Order $order): self
  43.     {
  44.         if (!$this->orders->contains($order)) {
  45.             $this->orders->add($order);
  46.             $order->setOrderStatus($this);
  47.         }
  48.         return $this;
  49.     }
  50.     public function removeOrder(Order $order): self
  51.     {
  52.         if ($this->orders->removeElement($order)) {
  53.             // set the owning side to null (unless already changed)
  54.             if ($order->getOrderStatus() === $this) {
  55.                 $order->setOrderStatus(null);
  56.             }
  57.         }
  58.         return $this;
  59.     }
  60.     public function __toString(): string
  61.     {
  62.         return $this->getStatusName();
  63.     }
  64. }