src/Entity/Sectoral.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SectoralRepository;
  4. use DateTimeImmutable;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClass: SectoralRepository::class)]
  9. class Sectoral
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id = null;
  15.     #[ORM\Column(length: 255)]
  16.     private ?string $label = null;
  17.     #[ORM\Column(length: 15)]
  18.     private ?string $code = null;
  19.     #[ORM\OneToMany(mappedBy: 'sectoral', targetEntity: User::class)]
  20.     private Collection $user;
  21.     #[ORM\ManyToOne]
  22.     private ?User $createdBy = null;
  23.     #[ORM\ManyToOne]
  24.     private ?User $updatedBy = null;
  25.     #[ORM\Column]
  26.     private ?DateTimeImmutable $createdAt = null;
  27.     #[ORM\Column(nullable: true)]
  28.     private ?DateTimeImmutable $updatedAt = null;
  29.     public function __construct()
  30.     {
  31.         $this->user = new ArrayCollection();
  32.         $this->createdAt = new DateTimeImmutable();
  33.         $this->updatedAt = new DateTimeImmutable();
  34.     }
  35.     public function getId(): ?int
  36.     {
  37.         return $this->id;
  38.     }
  39.     public function getLabel(): ?string
  40.     {
  41.         return $this->label;
  42.     }
  43.     public function setLabel(string $label): self
  44.     {
  45.         $this->label = $label;
  46.         return $this;
  47.     }
  48.     public function getCode(): ?string
  49.     {
  50.         return $this->code;
  51.     }
  52.     public function setCode(string $code): self
  53.     {
  54.         $this->code = $code;
  55.         return $this;
  56.     }
  57.     /**
  58.      * @return Collection<int, User>
  59.      */
  60.     public function getUser(): Collection
  61.     {
  62.         return $this->user;
  63.     }
  64.     public function addUser(User $user): self
  65.     {
  66.         if (!$this->user->contains($user)) {
  67.             $this->user->add($user);
  68.             $user->setSectoral($this);
  69.         }
  70.         return $this;
  71.     }
  72.     public function removeUser(User $user): self
  73.     {
  74.         if ($this->user->removeElement($user)) {
  75.             // set the owning side to null (unless already changed)
  76.             if ($user->getSectoral() === $this) {
  77.                 $user->setSectoral(null);
  78.             }
  79.         }
  80.         return $this;
  81.     }
  82.     public function getCreatedBy(): ?User
  83.     {
  84.         return $this->createdBy;
  85.     }
  86.     public function setCreatedBy(?User $createdBy): self
  87.     {
  88.         $this->createdBy = $createdBy;
  89.         return $this;
  90.     }
  91.     public function getUpdatedBy(): ?User
  92.     {
  93.         return $this->updatedBy;
  94.     }
  95.     public function setUpdatedBy(?User $updatedBy): self
  96.     {
  97.         $this->updatedBy = $updatedBy;
  98.         return $this;
  99.     }
  100.     public function getCreatedAt(): ?DateTimeImmutable
  101.     {
  102.         return $this->createdAt;
  103.     }
  104.     public function setCreatedAt(DateTimeImmutable $createdAt): self
  105.     {
  106.         $this->createdAt = $createdAt;
  107.         return $this;
  108.     }
  109.     public function getUpdatedAt(): ?DateTimeImmutable
  110.     {
  111.         return $this->updatedAt;
  112.     }
  113.     public function setUpdatedAt(?DateTimeImmutable $updatedAt): self
  114.     {
  115.         $this->updatedAt = $updatedAt;
  116.         return $this;
  117.     }
  118.     public function __toString(): string
  119.     {
  120.         return $this->label;
  121.     }
  122. }