src/Entity/Pays.php line 26
<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\GetCollection;
use App\Repository\PaysRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
#[ORM\Entity(repositoryClass: PaysRepository::class)]
#[ApiResource(
operations: [
new GetCollection(
normalizationContext: [
'groups' => ['read:pays:collection']
]
)
],
normalizationContext: [
'groups' => ['read:pays:collection']
]
)]
class Pays
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['read:course:item', 'read:user:item', 'read:pays:collection'])]
private ?int $id = null;
#[ORM\Column(length: 255)]
#[Groups(['read:course:item', 'read:user:item', 'read:pays:collection'])]
private ?string $name = null;
#[ORM\Column(length: 255)]
#[Groups(['read:course:item', 'read:user:item', 'read:pays:collection'])]
private ?string $slug = null;
#[ORM\Column(length: 100)]
#[Groups(['read:course:item', 'read:user:item', 'read:pays:collection'])]
private ?string $code = null;
#[ORM\OneToMany(mappedBy: 'pays', targetEntity: Personne::class)]
private Collection $personnes;
#[ORM\OneToMany(mappedBy: 'pays', targetEntity: Etablissement::class, orphanRemoval: true)]
private Collection $etablissements;
public function __construct()
{
$this->personnes = new ArrayCollection();
$this->etablissements = 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 getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(string $code): self
{
$this->code = $code;
return $this;
}
/**
* @return Collection<int, Personne>
*/
public function getPersonnes(): Collection
{
return $this->personnes;
}
public function addPersonne(Personne $personne): self
{
if (!$this->personnes->contains($personne)) {
$this->personnes->add($personne);
$personne->setPays($this);
}
return $this;
}
public function removePersonne(Personne $personne): self
{
if ($this->personnes->removeElement($personne)) {
// set the owning side to null (unless already changed)
if ($personne->getPays() === $this) {
$personne->setPays(null);
}
}
return $this;
}
/**
* @return Collection<int, Etablissement>
*/
public function getEtablissements(): Collection
{
return $this->etablissements;
}
public function addEtablissement(Etablissement $etablissement): self
{
if (!$this->etablissements->contains($etablissement)) {
$this->etablissements->add($etablissement);
$etablissement->setPays($this);
}
return $this;
}
public function removeEtablissement(Etablissement $etablissement): self
{
if ($this->etablissements->removeElement($etablissement)) {
// set the owning side to null (unless already changed)
if ($etablissement->getPays() === $this) {
$etablissement->setPays(null);
}
}
return $this;
}
}