src/Flexy/ShopBundle/Entity/Shipping/ShipmentItemType.php line 14

  1. <?php
  2. namespace App\Flexy\ShopBundle\Entity\Shipping;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\Flexy\ShopBundle\Entity\Shipping\ShipmentItemTypeRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. #[ORM\Entity(repositoryClassShipmentItemTypeRepository::class)]
  10. #[ApiResource]
  11. class ShipmentItemType
  12. {
  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(length255nullabletrue)]
  20.     private ?string $description null;
  21.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  22.     private ?\DateTimeInterface $createdAt null;
  23.     #[ORM\OneToMany(mappedBy'shipmentItemType'targetEntityShipmentItem::class)]
  24.     private Collection $shipmentItems;
  25.     public function __construct()
  26.     {
  27.         $this->shipmentItems = new ArrayCollection();
  28.     }
  29.     public function __toString()
  30.     {
  31.         return $this->name;
  32.     }
  33.     public function getId(): ?int
  34.     {
  35.         return $this->id;
  36.     }
  37.     public function getName(): ?string
  38.     {
  39.         return $this->name;
  40.     }
  41.     public function setName(string $name): self
  42.     {
  43.         $this->name $name;
  44.         return $this;
  45.     }
  46.     public function getDescription(): ?string
  47.     {
  48.         return $this->description;
  49.     }
  50.     public function setDescription(?string $description): self
  51.     {
  52.         $this->description $description;
  53.         return $this;
  54.     }
  55.     public function getCreatedAt(): ?\DateTimeInterface
  56.     {
  57.         return $this->createdAt;
  58.     }
  59.     public function setCreatedAt(?\DateTimeInterface $createdAt): self
  60.     {
  61.         $this->createdAt $createdAt;
  62.         return $this;
  63.     }
  64.     /**
  65.      * @return Collection<int, ShipmentItem>
  66.      */
  67.     public function getShipmentItems(): Collection
  68.     {
  69.         return $this->shipmentItems;
  70.     }
  71.     public function addShipmentItem(ShipmentItem $shipmentItem): self
  72.     {
  73.         if (!$this->shipmentItems->contains($shipmentItem)) {
  74.             $this->shipmentItems->add($shipmentItem);
  75.             $shipmentItem->setShipmentItemType($this);
  76.         }
  77.         return $this;
  78.     }
  79.     public function removeShipmentItem(ShipmentItem $shipmentItem): self
  80.     {
  81.         if ($this->shipmentItems->removeElement($shipmentItem)) {
  82.             // set the owning side to null (unless already changed)
  83.             if ($shipmentItem->getShipmentItemType() === $this) {
  84.                 $shipmentItem->setShipmentItemType(null);
  85.             }
  86.         }
  87.         return $this;
  88.     }
  89. }