<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\VoucherRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: VoucherRepository::class)]
#[ApiResource]
class Voucher
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $code = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $date = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $etat = null;
#[ORM\ManyToOne(inversedBy: 'vouchers')]
private ?Offresinscrit $userinscrit = null;
#[ORM\ManyToOne(inversedBy: 'voucher')]
private ?Offres $offres = null;
#[ORM\OneToMany(mappedBy: 'voucher', targetEntity: Utilisation::class,cascade: ['remove'])]
private Collection $utilisations;
#[ORM\Column(length: 255, nullable: true)]
private ?string $partner = null;
public function __construct()
{
$this->utilisations = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(?string $code): self
{
$this->code = $code;
return $this;
}
public function getDate(): ?\DateTimeInterface
{
return $this->date;
}
public function setDate(?\DateTimeInterface $date): self
{
$this->date = $date;
return $this;
}
public function getEtat(): ?string
{
return $this->etat;
}
public function setEtat(?string $etat): self
{
$this->etat = $etat;
return $this;
}
public function getUserinscrit(): ?Offresinscrit
{
return $this->userinscrit;
}
public function setUserinscrit(?Offresinscrit $userinscrit): self
{
$this->userinscrit = $userinscrit;
return $this;
}
public function getOffres(): ?Offres
{
return $this->offres;
}
public function setOffres(?Offres $offres): self
{
$this->offres = $offres;
return $this;
}
/**
* @return Collection<int, Utilisation>
*/
public function getUtilisations(): Collection
{
return $this->utilisations;
}
public function addUtilisation(Utilisation $utilisation): self
{
if (!$this->utilisations->contains($utilisation)) {
$this->utilisations->add($utilisation);
$utilisation->setVoucher($this);
}
return $this;
}
public function removeUtilisation(Utilisation $utilisation): self
{
if ($this->utilisations->removeElement($utilisation)) {
// set the owning side to null (unless already changed)
if ($utilisation->getVoucher() === $this) {
$utilisation->setVoucher(null);
}
}
return $this;
}
public function getPartner(): ?string
{
return $this->partner;
}
public function setPartner(?string $partner): self
{
$this->partner = $partner;
return $this;
}
}