src/Flexy/ShopBundle/Entity/Shipping/Vehicle/VehicleRentType.php line 13

  1. <?php
  2. namespace App\Flexy\ShopBundle\Entity\Shipping\Vehicle;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\Flexy\ShopBundle\Entity\Shipping\Vehicle\VehicleRentTypeRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassVehicleRentTypeRepository::class)]
  9. #[ApiResource]
  10. class VehicleRentType
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[ORM\Column(length255nullabletrue)]
  17.     private ?string $name null;
  18.     #[ORM\OneToMany(mappedBy'vehicleRentType'targetEntityShippingVehicle::class)]
  19.     private Collection $shippingVehicles;
  20.     public function __construct()
  21.     {
  22.         $this->shippingVehicles = new ArrayCollection();
  23.     }
  24.     public function getId(): ?int
  25.     {
  26.         return $this->id;
  27.     }
  28.     public function getName(): ?string
  29.     {
  30.         return $this->name;
  31.     }
  32.     public function setName(?string $name): self
  33.     {
  34.         $this->name $name;
  35.         return $this;
  36.     }
  37.     /**
  38.      * @return Collection<int, ShippingVehicle>
  39.      */
  40.     public function getShippingVehicles(): Collection
  41.     {
  42.         return $this->shippingVehicles;
  43.     }
  44.     public function addShippingVehicle(ShippingVehicle $shippingVehicle): self
  45.     {
  46.         if (!$this->shippingVehicles->contains($shippingVehicle)) {
  47.             $this->shippingVehicles->add($shippingVehicle);
  48.             $shippingVehicle->setVehicleRentType($this);
  49.         }
  50.         return $this;
  51.     }
  52.     public function removeShippingVehicle(ShippingVehicle $shippingVehicle): self
  53.     {
  54.         if ($this->shippingVehicles->removeElement($shippingVehicle)) {
  55.             // set the owning side to null (unless already changed)
  56.             if ($shippingVehicle->getVehicleRentType() === $this) {
  57.                 $shippingVehicle->setVehicleRentType(null);
  58.             }
  59.         }
  60.         return $this;
  61.     }
  62. }