src/Entity/Department.php line 12

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\DepartmentRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassDepartmentRepository::class)]
  9. class Department
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column(length2)]
  14.     private ?string $departmentCode null;
  15.     #[ORM\Column(length255)]
  16.     private ?string $name null;
  17.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  18.     private ?string $description null;
  19.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  20.     private ?\DateTimeInterface $updated null;
  21.     #[ORM\Column]
  22.     private ?int $updatedBy null;
  23.     #[ORM\OneToMany(mappedBy'department'targetEntityTeamMember::class)]
  24.     private Collection $teamMembers;
  25.     public function __construct()
  26.     {
  27.         $this->teamMembers = new ArrayCollection();
  28.     }
  29.     public function getDepartmentCode(): ?string
  30.     {
  31.         return $this->departmentCode;
  32.     }
  33.     public function setDepartmentCode(string $departmentCode): static
  34.     {
  35.         $this->departmentCode $departmentCode;
  36.         return $this;
  37.     }
  38.     public function getName(): ?string
  39.     {
  40.         return $this->name;
  41.     }
  42.     public function setName(string $name): static
  43.     {
  44.         $this->name $name;
  45.         return $this;
  46.     }
  47.     public function getDescription(): ?string
  48.     {
  49.         return $this->description;
  50.     }
  51.     public function setDescription(?string $description): static
  52.     {
  53.         $this->description $description;
  54.         return $this;
  55.     }
  56.     public function getUpdatedBy(): ?int
  57.     {
  58.         return $this->updatedBy;
  59.     }
  60.     public function setUpdatedBy(int $updatedBy): static
  61.     {
  62.         $this->updatedBy $updatedBy;
  63.         return $this;
  64.     }
  65.     /**
  66.      * @return Collection<int, TeamMember>
  67.      */
  68.     public function getTeamMembers(): Collection
  69.     {
  70.         return $this->teamMembers;
  71.     }
  72.     public function addTeamMember(TeamMember $teamMember): static
  73.     {
  74.         if (!$this->teamMembers->contains($teamMember)) {
  75.             $this->teamMembers->add($teamMember);
  76.             $teamMember->setDepartment($this);
  77.         }
  78.         return $this;
  79.     }
  80.     public function removeTeamMember(TeamMember $teamMember): static
  81.     {
  82.         if ($this->teamMembers->removeElement($teamMember)) {
  83.             // set the owning side to null (unless already changed)
  84.             if ($teamMember->getDepartment() === $this) {
  85.                 $teamMember->setDepartment(null);
  86.             }
  87.         }
  88.         return $this;
  89.     }
  90. }