<?php
namespace App\Entity;
use App\Repository\CouponUserRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: CouponUserRepository::class)]
class CouponUser
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(nullable: true)]
private ?bool $isActive = null;
#[ORM\ManyToOne(inversedBy: 'coupon')]
#[ORM\JoinColumn(nullable: false)]
private ?User $user = null;
#[ORM\ManyToOne(inversedBy: 'couponUsers')]
#[ORM\JoinColumn(nullable: false)]
private ?Offre $offre = null;
#[ORM\Column(length: 255)]
private ?string $qrCodePath = null;
#[ORM\Column]
private ?\DateTimeImmutable $createdAt = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $dateUsed = null;
#[ORM\Column(length: 255)]
private ?string $slug = null;
public function getId(): ?int
{
return $this->id;
}
public function isIsActive(): ?bool
{
return $this->isActive;
}
public function setIsActive(?bool $isActive): static
{
$this->isActive = $isActive;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): static
{
$this->user = $user;
return $this;
}
public function getOffre(): ?Offre
{
return $this->offre;
}
public function setOffre(?Offre $offre): static
{
$this->offre = $offre;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeImmutable $createdAt): static
{
$this->createdAt = $createdAt;
return $this;
}
public function getDateUsed(): ?\DateTimeInterface
{
return $this->dateUsed;
}
public function setDateUsed(?\DateTimeInterface $dateUsed): ?static
{
$this->dateUsed = $dateUsed;
return $this;
}
public function getQrCodePath(): ?string
{
return $this->qrCodePath;
}
public function setQrCodePath(string $qrCodePath): static
{
$this->qrCodePath = $qrCodePath;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): static
{
$this->slug = $slug;
return $this;
}
public function getExpirationDate(): \DateTimeImmutable|bool
{
$expirationDate = clone $this->createdAt; // ou $this->createdAt selon votre logique
return $expirationDate->modify('+3 month');
}
public function getTypeEntity(): string
{
return 'coupon';
}
}