src/Domains/UserPlan/Domain/Entity/UserSubscription.php line 14

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Domains\UserPlan\Domain\Entity;
  4. use App\Domains\Plan\Domain\Entity\Plan;
  5. use App\Domains\User\Domain\Entity\User;
  6. use DateTimeImmutable;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity]
  9. #[ORM\Table(name'user_subscription')]
  10. class UserSubscription
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column(type'integer')]
  15.     private int|null $id null;
  16.     #[ORM\ManyToOne(targetEntityUser::class)]
  17.     #[ORM\JoinColumn(nullablefalse)]
  18.     private User $user;
  19.     #[ORM\ManyToOne(targetEntityPlan::class)]
  20.     #[ORM\JoinColumn(nullablefalse)]
  21.     private Plan $plan;
  22.     #[ORM\Column(type'datetime_immutable')]
  23.     private DateTimeImmutable $startDate;
  24.     #[ORM\Column(type'datetime_immutable')]
  25.     private DateTimeImmutable $endDate;
  26.     #[ORM\Column(type'boolean')]
  27.     private bool $isActive;
  28.     public function __construct(
  29.         User $user,
  30.         Plan $plan,
  31.         DateTimeImmutable $startDate,
  32.         DateTimeImmutable $endDate
  33.     ) {
  34.         $this->user $user;
  35.         $this->plan $plan;
  36.         $this->startDate $startDate;
  37.         $this->endDate $endDate;
  38.         $this->isActive true;
  39.     }
  40.     // Getters
  41.     public function getId(): int|null
  42.     {
  43.         return $this->id;
  44.     }
  45.     public function getUser(): User
  46.     {
  47.         return $this->user;
  48.     }
  49.     public function getPlan(): Plan
  50.     {
  51.         return $this->plan;
  52.     }
  53.     public function getStartDate(): DateTimeImmutable
  54.     {
  55.         return $this->startDate;
  56.     }
  57.     public function getEndDate(): DateTimeImmutable
  58.     {
  59.         return $this->endDate;
  60.     }
  61.     public function isActive(): bool
  62.     {
  63.         return $this->isActive;
  64.     }
  65.     public function deactivate(): void
  66.     {
  67.         $this->isActive false;
  68.     }
  69. }