src/Entity/Module.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ModuleRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Validator\Constraints as Assert;
  6. #[ORM\Entity(repositoryClassModuleRepository::class)]
  7. #[ORM\Table(name'tb_modules')]
  8. #[ORM\HasLifecycleCallbacks]
  9. class Module
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column(type"integer"uniquetrue)]
  14.     private ?int $id;
  15.     #[ORM\Column(type'string'length50nullablefalse)]
  16.     private ?string $code;
  17.     #[ORM\Column(type'string'length50nullablefalse)]
  18.     #[Assert\NotBlank(message"Saisir un nom pour le module")]
  19.     private ?string $name;
  20.     #[ORM\Column(type'boolean'nullabletrue)]
  21.     private ?bool $activated;
  22.     #[ORM\Column(type'datetime'nullablefalse)]
  23.     private \DateTimeInterface $createdAt;
  24.     #[ORM\Column(type'datetime'nullablefalse)]
  25.     private ?\DateTimeInterface $modifiedAt;
  26.     #[ORM\ManyToOne]
  27.     private ?User $createdBy null;
  28.     public function __construct()
  29.     {
  30.         $this->createdAt = new \DateTime();
  31.     }
  32.     public function getId(): ?int
  33.     {
  34.         return $this->id;
  35.     }
  36.     public function getCode(): ?string
  37.     {
  38.         return $this->code;
  39.     }
  40.     public function setCode(string $code): self
  41.     {
  42.         $this->code $code;
  43.         return $this;
  44.     }
  45.     public function getName(): ?string
  46.     {
  47.         return $this->name;
  48.     }
  49.     public function setName(string $name): self
  50.     {
  51.         $this->name $name;
  52.         return $this;
  53.     }
  54.     public function getActivated(): ?bool
  55.     {
  56.         return $this->activated;
  57.     }
  58.     public function setActivated(?bool $activated): self
  59.     {
  60.         $this->activated $activated;
  61.         return $this;
  62.     }
  63.     public function getCreatedAt(): ?\DateTimeInterface
  64.     {
  65.         return $this->createdAt;
  66.     }
  67.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  68.     {
  69.         $this->createdAt $createdAt;
  70.         return $this;
  71.     }
  72.     public function getModifiedAt(): ?\DateTimeInterface
  73.     {
  74.         return $this->modifiedAt;
  75.     }
  76.     public function setModifiedAt(?\DateTimeInterface $modifiedAt): self
  77.     {
  78.         $this->modifiedAt $modifiedAt;
  79.         return $this;
  80.     }
  81.     /**
  82.      * @ORM\PreUpdate
  83.      */
  84.     public function onUpdate() {
  85.         $this->modifiedAt = new \DateTime();
  86.     }
  87.     public function getCreatedBy(): ?User
  88.     {
  89.         return $this->createdBy;
  90.     }
  91.     public function setCreatedBy(?User $createdBy): static
  92.     {
  93.         $this->createdBy $createdBy;
  94.         return $this;
  95.     }
  96. }