'\d+'], normalizationContext: ['groups' => ['vehicle:read']], ), new GetCollection( normalizationContext: ['groups' => ['vehicle:read']], ), ], security: "is_granted('ROLE_USER')", )] class Vehicle { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] #[Groups(['vehicle:read'])] private ?int $id = null; #[ORM\Column(length: 20)] #[Groups(['vehicle:read'])] private string $plate = ''; #[ORM\ManyToOne] #[ORM\JoinColumn(nullable: false)] #[Groups(['vehicle:read'])] #[ApiProperty(readableLink: true)] private ?Carrier $carrier = null; #[ORM\ManyToOne] #[ORM\JoinColumn(nullable: false)] #[Groups(['vehicle:read'])] #[ApiProperty(readableLink: true)] private ?Truck $truck = null; /** * @var Collection */ #[ORM\OneToMany(targetEntity: Shipment::class, mappedBy: 'id_carrier_1')] private Collection $shipments; public function __construct() { $this->shipments = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getPlate(): string { return $this->plate; } public function setPlate(string $plate): self { $this->plate = $plate; return $this; } public function getCarrier(): ?Carrier { return $this->carrier; } public function setCarrier(?Carrier $carrier): self { $this->carrier = $carrier; return $this; } public function getTruck(): ?Truck { return $this->truck; } public function setTruck(?Truck $truck): self { $this->truck = $truck; return $this; } /** * @return Collection */ public function getShipments(): Collection { return $this->shipments; } public function addShipment(Shipment $shipment): static { if (!$this->shipments->contains($shipment)) { $this->shipments->add($shipment); $shipment->setIdCarrier1($this); } return $this; } public function removeShipment(Shipment $shipment): static { if ($this->shipments->removeElement($shipment)) { // set the owning side to null (unless already changed) if ($shipment->getIdCarrier1() === $this) { $shipment->setIdCarrier1(null); } } return $this; } }