<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\TypeModePayementRepository;
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: TypeModePayementRepository::class)]
#[ApiResource(
denormalizationContext:[
'groups'=>['TypeModePayement:write']
],
normalizationContext:[
'groups'=>['TypeModePayement:read']
],
)]
class TypeModePayement
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
#[Groups(['TypeModePayement:read'])]
private $id;
#[ORM\Column(type: 'string', length: 90, nullable: true)]
#[Groups(['TypeModePayement:read'])]
private $label;
#[ORM\Column(type: 'integer', nullable: true)]
#[Groups(['TypeModePayement:read'])]
private $code;
#[ORM\OneToMany(mappedBy: 'typeModePayement', targetEntity: ModePayement::class)]
#[Groups(['TypeModePayement:read'])]
private $modePayements;
public function __construct()
{
$this->modePayements = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(?string $label): self
{
$this->label = $label;
return $this;
}
public function getCode(): ?int
{
return $this->code;
}
public function setCode(?int $code): self
{
$this->code = $code;
return $this;
}
/**
* @return Collection<int, ModePayement>
*/
public function getModePayements(): Collection
{
return $this->modePayements;
}
public function addModePayement(ModePayement $modePayement): self
{
if (!$this->modePayements->contains($modePayement)) {
$this->modePayements[] = $modePayement;
$modePayement->setTypeModePayement($this);
}
return $this;
}
public function removeModePayement(ModePayement $modePayement): self
{
if ($this->modePayements->removeElement($modePayement)) {
// set the owning side to null (unless already changed)
if ($modePayement->getTypeModePayement() === $this) {
$modePayement->setTypeModePayement(null);
}
}
return $this;
}
}