<?php namespace App\Entity; use App\Repository\UserSubscriptionRepository; use DateTimeImmutable; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity(repositoryClass=UserSubscriptionRepository::class) */ class UserSubscription { /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private ?int $id = NULL; /** * Utilisateur rattaché à l'abonnement * * @ORM\OneToOne(targetEntity=User::class, mappedBy="subscription") * @ORM\JoinColumn(nullable=false) */ private ?User $user = NULL; /** * Type d'abonnement rattaché * * @ORM\ManyToOne(targetEntity=Subscription::class, inversedBy="userSubscriptions", cascade={"persist"}) * @ORM\JoinColumn(nullable=false) */ private ?Subscription $subscription = NULL; /** * Date de début de l'abonnement * * @ORM\Column(type="datetime_immutable") */ private ?DateTimeImmutable $subscribedAt; /** * Date de fin de l'abonnement * * @ORM\Column(type="datetime_immutable") */ private ?DateTimeImmutable $endAt = NULL; /** * Nombre fois que l'abonnement a été renouvelé * * @ORM\Column(type="integer", options={"default": 0}) */ private int $renewalNumber = 0; /** * @ORM\Column(type="datetime_immutable", nullable=true) */ private ?DateTimeImmutable $renewedAt = NULL; public function __construct() { $this->subscribedAt = new DateTimeImmutable(); } public function getId(): ?int { return $this->id; } public function getUser(): ?User { return $this->user; } public function setUser(User $user): self { $this->user = $user; return $this; } public function getSubscription(): ?Subscription { return $this->subscription; } public function setSubscription(Subscription $subscription): self { $this->subscription = $subscription; return $this; } public function getSubscribedAt(): ?DateTimeImmutable { return $this->subscribedAt; } public function setSubscribedAt(?DateTimeImmutable $subscribedAt): self { if ($subscribedAt === NULL) { $subscribedAt = new DateTimeImmutable(); } $this->subscribedAt = $subscribedAt; return $this; } public function getEndAt(): ?DateTimeImmutable { return $this->endAt; } public function setEndAt(DateTimeImmutable $endAt): self { $this->endAt = $endAt; return $this; } public function getRenewalNumber(): ?int { return $this->renewalNumber; } public function setRenewalNumber(int $renewalNumber): self { $this->renewalNumber = $renewalNumber; return $this; } public function getRenewedAt(): ?DateTimeImmutable { return $this->renewedAt; } public function setRenewedAt(?DateTimeImmutable $renewedAt): self { $this->renewedAt = $renewedAt; return $this; } }