src/Flexy/ShopBundle/Entity/Shipping/Vehicle/FuelType.php line 14

  1. <?php
  2. namespace App\Flexy\ShopBundle\Entity\Shipping\Vehicle;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\Flexy\ShopBundle\Entity\Shipping\Vehicle\FuelTypeRepository;
  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(repositoryClassFuelTypeRepository::class)]
  10. #[ApiResource]
  11. class FuelType
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\Column(length255nullabletrue)]
  18.     private ?string $title null;
  19.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  20.     private ?string $description null;
  21.     #[ORM\OneToMany(mappedBy'fuelType'targetEntityShippingVehicle::class)]
  22.     private Collection $shippingVehicles;
  23.     public function __toString()
  24.     {
  25.         return $this->title;
  26.     }
  27.     public function __construct()
  28.     {
  29.         $this->shippingVehicles = new ArrayCollection();
  30.     }
  31.     public function getId(): ?int
  32.     {
  33.         return $this->id;
  34.     }
  35.     public function getTitle(): ?string
  36.     {
  37.         return $this->title;
  38.     }
  39.     public function setTitle(?string $title): self
  40.     {
  41.         $this->title $title;
  42.         return $this;
  43.     }
  44.     public function getDescription(): ?string
  45.     {
  46.         return $this->description;
  47.     }
  48.     public function setDescription(?string $description): self
  49.     {
  50.         $this->description $description;
  51.         return $this;
  52.     }
  53.     /**
  54.      * @return Collection<int, ShippingVehicle>
  55.      */
  56.     public function getShippingVehicles(): Collection
  57.     {
  58.         return $this->shippingVehicles;
  59.     }
  60.     public function addShippingVehicle(ShippingVehicle $shippingVehicle): self
  61.     {
  62.         if (!$this->shippingVehicles->contains($shippingVehicle)) {
  63.             $this->shippingVehicles->add($shippingVehicle);
  64.             $shippingVehicle->setFuelType($this);
  65.         }
  66.         return $this;
  67.     }
  68.     public function removeShippingVehicle(ShippingVehicle $shippingVehicle): self
  69.     {
  70.         if ($this->shippingVehicles->removeElement($shippingVehicle)) {
  71.             // set the owning side to null (unless already changed)
  72.             if ($shippingVehicle->getFuelType() === $this) {
  73.                 $shippingVehicle->setFuelType(null);
  74.             }
  75.         }
  76.         return $this;
  77.     }
  78. }