src/Entity/ModuleLicense.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use App\Repository\ModuleLicenseRepository;
  5. use App\Enums\ModuleLicenseType;
  6. #[ORM\Table('module_license')]
  7. #[ORM\Entity(ModuleLicenseRepository::class)]
  8. class ModuleLicense implements \JsonSerializable
  9. {
  10.     #[ORM\Column('id''integer')]
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue('IDENTITY')]
  13.     private ?int $id;
  14.     #[ORM\ManyToOne(Customer::class, inversedBy'moduleLicense')]
  15.     #[ORM\JoinColumn('customer')]
  16.     private Customer $customer;
  17.     #[ORM\ManyToOne(Module::class)]
  18.     #[ORM\JoinColumn('module')]
  19.     private ?Module $module;
  20.     #[ORM\Column('type''string'enumTypeModuleLicenseType::class, nullabletrue)]
  21.     private ?ModuleLicenseType $type null;
  22.     #[ORM\Column('license_date_limit''datetime_immutable'nullabletrue)]
  23.     private ?\DateTimeImmutable $dateLimit null;
  24.     #[ORM\Column('active''boolean')]
  25.     private bool $active false;
  26.     public function __construct(Customer $customer)
  27.     {
  28.         $this->customer $customer;
  29.     }
  30.     public function getId(): ?int
  31.     {
  32.         return $this->id;
  33.     }
  34.     public function setId(int $id): ModuleLicense
  35.     {
  36.         $this->id $id;
  37.         return $this;
  38.     }
  39.     public function getCustomer(): Customer
  40.     {
  41.         return $this->customer;
  42.     }
  43.     public function setCustomer(Customer $customer): ModuleLicense
  44.     {
  45.         $this->customer $customer;
  46.         return $this;
  47.     }
  48.     public function getDateLimit(): ?\DateTimeImmutable
  49.     {
  50.         return $this->dateLimit;
  51.     }
  52.     public function setDateLimit(?\DateTimeImmutable $dateLimit): ModuleLicense
  53.     {
  54.         if ($dateLimit) {
  55.             $dateLimit->setTime(235959);
  56.         }
  57.         $this->dateLimit $dateLimit;
  58.         return $this;
  59.     }
  60.     public function getModule(): ?Module
  61.     {
  62.         return $this->module;
  63.     }
  64.     public function setModule(?Module $module): ModuleLicense
  65.     {
  66.         $this->module $module;
  67.         return $this;
  68.     }
  69.     public function getType(): ?ModuleLicenseType
  70.     {
  71.         return $this->type;
  72.     }
  73.     public function setType(?ModuleLicenseType $type): ModuleLicense
  74.     {
  75.         $this->type $type;
  76.         return $this;
  77.     }
  78.     public function isActive(): bool
  79.     {
  80.         return $this->active;
  81.     }
  82.     public function setActive(bool $active): ModuleLicense
  83.     {
  84.         $this->active $active;
  85.         return $this;
  86.     }
  87.     public function jsonSerialize(): array
  88.     {
  89.         return [
  90.             'id' => $this->getModule()->getId(),
  91.             'title' => $this->getModule()->getTitle(),
  92.             'systemName' => $this->getModule()->getSystemName(),
  93.             'dateLimit' => $this->getDateLimit()?->format('Y-m-d'),
  94.             'customer' => $this->getCustomer(),
  95.             'module' => $this->getModule(),
  96.             'active' => $this->isActive(),
  97.             'type' => $this->getType()?->value,
  98.         ];
  99.     }
  100. }