src/Entity/Country.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use ApiPlatform\Metadata\ApiResource;
  5. use Symfony\Component\Serializer\Annotation\Groups;
  6. #[ORM\Table(name'country')]
  7. #[ORM\Entity]
  8. #[ApiResource(normalizationContext: ['groups' => ['country.get','document.get']])]
  9. class Country
  10. {
  11.     #[ORM\Column(name'id'type'integer'nullablefalse)]
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue(strategy'IDENTITY')]
  14.     #[Groups(['country.get','document.get','site.get'])]
  15.     private int $id;
  16.     #[ORM\Column(name'name'type'string'nullablefalse)]
  17.     #[Groups(['country.get','document.get','site.get'])]
  18.     private string $name;
  19.     #[ORM\Column(length20)]
  20.     #[Groups(['country.get','document.get','site.get'])]
  21.     private ?string $code null;
  22.     public function getId(): ?int
  23.     {
  24.         return $this->id;
  25.     }
  26.     public function getName(): string
  27.     {
  28.         return $this->name;
  29.     }
  30.     public function setName($name): self
  31.     {
  32.         $this->name $name;
  33.         return $this;
  34.     }
  35.     public function getCode(): ?string
  36.     {
  37.         return $this->code;
  38.     }
  39.     public function setCode(string $code): self
  40.     {
  41.         $this->code $code;
  42.         return $this;
  43.     }
  44. }