'\d+'], normalizationContext: ['groups' => ['supplier:read']], ), new GetCollection( normalizationContext: ['groups' => ['supplier:read']], ), new GetCollection( uriTemplate: '/admin/suppliers', normalizationContext: ['groups' => ['supplier:read']], security: "is_granted('ROLE_ADMIN')" ), new Post( normalizationContext: ['groups' => ['supplier:read']], denormalizationContext: ['groups' => ['supplier:write']], security: "is_granted('ROLE_ADMIN')", ), new Patch( normalizationContext: ['groups' => ['supplier:read']], denormalizationContext: ['groups' => ['supplier:write']], security: "is_granted('ROLE_ADMIN')", ), ], security: "is_granted('ROLE_USER')", )] class Supplier { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] #[Groups(['supplier:read', 'reception:read'])] private ?int $id = null; #[ORM\Column(length: 180)] #[Groups(['supplier:read', 'reception:read', 'supplier:write'])] private string $name = ''; #[ORM\Column(length: 180, nullable: true)] #[Groups(['supplier:read', 'reception:read', 'supplier:write'])] private ?string $email = null; #[ORM\Column(length: 40, nullable: true)] #[Groups(['supplier:read', 'reception:read', 'supplier:write'])] private ?string $phone = null; /** * @var Collection */ #[ORM\ManyToMany(targetEntity: Address::class, inversedBy: 'suppliers')] #[ORM\JoinTable(name: 'supplier_address')] #[Groups(['supplier:read', 'supplier:write'])] #[ApiProperty(readableLink: true)] private Collection $addresses; public function __construct() { $this->addresses = 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; return $this; } public function getEmail(): ?string { return $this->email; } public function setEmail(?string $email): self { $this->email = $email; return $this; } public function getPhone(): ?string { return $this->phone; } public function setPhone(?string $phone): self { $this->phone = $phone; return $this; } /** * @return Collection */ public function getAddresses(): Collection { return $this->addresses; } public function setAddresses(iterable $addresses): self { $this->addresses->clear(); foreach ($addresses as $address) { $this->addAddress($address); } return $this; } public function addAddress(Address $address): self { if (!$this->addresses->contains($address)) { $this->addresses->add($address); } return $this; } public function removeAddress(Address $address): self { $this->addresses->removeElement($address); return $this; } }