src/Entity/VehicleModel.php line 30
<?phpnamespace App\Entity;use ApiPlatform\Doctrine\Orm\Filter\BooleanFilter;use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;use ApiPlatform\Metadata\ApiFilter;use ApiPlatform\Metadata\ApiResource;use ApiPlatform\Metadata\Get;use ApiPlatform\Metadata\GetCollection;use App\Repository\VehicleModelRepository;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(),new GetCollection()],normalizationContext: ['groups' => ['model:read']],security: "is_granted('PUBLIC_ACCESS')")]#[ApiFilter(BooleanFilter::class, properties: ['vehicles.visible'])]#[ApiFilter(SearchFilter::class, properties: ['vehicles.manufacturer' => 'exact', 'vehicles.manufacturer.url' => 'exact', 'vehicles.category.url' => 'exact', 'vehicles.kind' => 'exact' ])]#[ORM\Entity(repositoryClass: VehicleModelRepository::class)]class VehicleModel{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]#[Groups(['vehicle:read', 'model:read'])]private ?int $id = null;#[Groups(['vehicle:read', 'model:read'])]#[ORM\Column(length: 255)]private ?string $name = null;#[ORM\OneToMany(mappedBy: 'model', targetEntity: Vehicle::class)]private Collection $vehicles;#[Groups(['vehicle:read', 'model:read'])]#[ORM\Column(length: 255)]private ?string $url = null;#[ORM\OneToMany(mappedBy: 'vehicleModel', targetEntity: Blog::class)]private Collection $blogs;#[ORM\ManyToOne(inversedBy: 'vehicleModels')]private ?VehicleManufacturer $vehicleManufacturer = null;public function __construct(){$this->vehicles = new ArrayCollection();$this->blogs = new ArrayCollection();}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($this->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->setModel($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->getModel() === $this) {$vehicle->setModel(null);}}return $this;}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;}/*** @return Collection<int, Blog>*/public function getBlogs(): Collection{return $this->blogs;}public function addBlog(Blog $blog): self{if (!$this->blogs->contains($blog)) {$this->blogs->add($blog);$blog->setVehicleModel($this);}return $this;}public function removeBlog(Blog $blog): self{if ($this->blogs->removeElement($blog)) {// set the owning side to null (unless already changed)if ($blog->getVehicleModel() === $this) {$blog->setVehicleModel(null);}}return $this;}public function getVehicleManufacturer(): ?VehicleManufacturer{return $this->vehicleManufacturer;}public function setVehicleManufacturer(?VehicleManufacturer $vehicleManufacturer): self{$this->vehicleManufacturer = $vehicleManufacturer;return $this;}}