src/Entity/VehicleBody.php line 23
<?phpnamespace App\Entity;use ApiPlatform\Metadata\ApiResource;use ApiPlatform\Metadata\Get;use App\Repository\VehicleBodyRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Serializer\Annotation\Groups;use Symfony\Component\String\Slugger\AsciiSlugger;#[ApiResource(operations: [new Get(),],normalizationContext: ['groups' => ['body:read']],security: "is_granted('PUBLIC_ACCESS')")]#[ORM\Entity(repositoryClass: VehicleBodyRepository::class)]class VehicleBody{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[Groups(['vehicle:read', 'body:read'])]#[ORM\Column(length: 255)]private ?string $name = null;#[ORM\Column(length: 255, unique: true)]private ?string $url = null;#[ORM\OneToMany(mappedBy: 'body', targetEntity: Vehicle::class)]private Collection $vehicles;public function __construct(){$this->vehicles = new ArrayCollection();}public function getUrl(): ?string{return $this->url;}public function setUrl(string $url): self{$slugger = new AsciiSlugger('cs');$slug = $slugger->slug($url, '-')->lower();$this->url = $slug->toString();return $this;}public function getId(): ?int{return $this->id;}public function getName(): ?string{return $this->name;}public function setName(string $name): self{$this->name = $name;$this->setUrl($name);return $this;}/*** @return Collection<int, Vehicle>*/public function getVehicles(): Collection{return $this->vehicles;}public function addVehicle(Vehicle $vehicle): self{if (!$this->vehicles->contains($vehicle)) {$this->vehicles->add($vehicle);$vehicle->setBody($this);}return $this;}public function removeVehicle(Vehicle $vehicle): self{if ($this->vehicles->removeElement($vehicle)) {// set the owning side to null (unless already changed)if ($vehicle->getBody() === $this) {$vehicle->setBody(null);}}return $this;}}