src/Entity/CRM/Department.php line 13

  1. <?php
  2. namespace App\Entity\CRM;
  3. use App\Entity\CRM\Worker;
  4. use App\Repository\DepartmentRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. #[ORM\Entity(repositoryClassDepartmentRepository::class)]
  10. class Department
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[ORM\Column(length255)]
  17.     private ?string $name null;
  18.     #[ORM\ManyToOne(inversedBy'departments')]
  19.     #[ORM\JoinColumn(nullablefalse)]
  20.     private ?Branch $branch null;
  21.     #[ORM\OneToMany(mappedBy'department'targetEntityConsultant::class)]
  22.     private Collection $consultants;
  23.     #[ORM\OneToMany(mappedBy'department'targetEntityWorker::class)]
  24.     private Collection $workers;
  25.     #[ORM\ManyToOne(inversedBy'department')]
  26.     private ?DepartmentType $departmentType null;
  27.     #[ORM\Column]
  28.     private bool $isActive true;
  29.     #[ORM\Column(length255)]
  30.     private ?string $color null;
  31.     #[ORM\Column]
  32.     private ?bool $mainDepartmentOfBranch null;
  33.     #[ORM\ManyToOne]
  34.     private ?Admin $orderSupervisor null;
  35.     #[ORM\Column(typeTypes::JSONnullabletrue)]
  36.     private ?array $accountingOfficeMailForNotification = [];
  37.     #[ORM\ManyToMany(targetEntityAdmin::class, inversedBy'departments')]
  38.     private Collection $management;
  39.     public function __construct()
  40.     {
  41.         $this->consultants = new ArrayCollection();
  42.         $this->workers = new ArrayCollection();
  43.         $this->isActive true;
  44.         $this->management = new ArrayCollection();
  45.     }
  46.     public function __toString()
  47.     {
  48.         return $this->id.' '.$this->name.' '.$this->branch;
  49.     }
  50.     public function getId(): ?int
  51.     {
  52.         return $this->id;
  53.     }
  54.     public function getName(): ?string
  55.     {
  56.         return $this->name;
  57.     }
  58.     public function setName(string $name): self
  59.     {
  60.         $this->name $name;
  61.         return $this;
  62.     }
  63.     public function getBranch(): ?Branch
  64.     {
  65.         return $this->branch;
  66.     }
  67.     public function setBranch(?Branch $branch): self
  68.     {
  69.         $this->branch $branch;
  70.         return $this;
  71.     }
  72.     /**
  73.      * @return Collection<int, Consultant>
  74.      */
  75.     public function getConsultants(): Collection
  76.     {
  77.         return $this->consultants;
  78.     }
  79.     public function addConsultant(Consultant $consultant): self
  80.     {
  81.         if (!$this->consultants->contains($consultant)) {
  82.             $this->consultants->add($consultant);
  83.             $consultant->setDepartment($this);
  84.         }
  85.         return $this;
  86.     }
  87.     public function removeConsultant(Consultant $consultant): self
  88.     {
  89.         if ($this->consultants->removeElement($consultant)) {
  90.             // set the owning side to null (unless already changed)
  91.             if ($consultant->getDepartment() === $this) {
  92.                 $consultant->setDepartment(null);
  93.             }
  94.         }
  95.         return $this;
  96.     }
  97.     /**
  98.      * @return Collection<int, Worker>
  99.      */
  100.     public function getWorkers(): Collection
  101.     {
  102.         return $this->workers;
  103.     }
  104.     public function addWorker(Worker $worker): self
  105.     {
  106.         if (!$this->workers->contains($worker)) {
  107.             $this->workers->add($worker);
  108.             $worker->setDepartment($this);
  109.         }
  110.         return $this;
  111.     }
  112.     public function removeWorker(Worker $worker): self
  113.     {
  114.         if ($this->workers->removeElement($worker)) {
  115.             // set the owning side to null (unless already changed)
  116.             if ($worker->getDepartment() === $this) {
  117.                 $worker->setDepartment(null);
  118.             }
  119.         }
  120.         return $this;
  121.     }
  122.     public function getDepartmentType(): ?DepartmentType
  123.     {
  124.         return $this->departmentType;
  125.     }
  126.     public function setDepartmentType(?DepartmentType $departmentType): static
  127.     {
  128.         $this->departmentType $departmentType;
  129.         return $this;
  130.     }
  131.     public function isIsActive(): ?bool
  132.     {
  133.         return $this->isActive;
  134.     }
  135.     public function setIsActive(bool $isActive): static
  136.     {
  137.         $this->isActive $isActive;
  138.         return $this;
  139.     }
  140.     public function getColor(): ?string
  141.     {
  142.         return $this->color;
  143.     }
  144.     public function setColor(string $color): static
  145.     {
  146.         $this->color $color;
  147.         return $this;
  148.     }
  149.     public function isMainDepartmentOfBranch(): ?bool
  150.     {
  151.         return $this->mainDepartmentOfBranch;
  152.     }
  153.     public function setMainDepartmentOfBranch(bool $mainDepartmentOfBranch): static
  154.     {
  155.         $this->mainDepartmentOfBranch $mainDepartmentOfBranch;
  156.         return $this;
  157.     }
  158.     public function getOrderSupervisor(): ?Admin
  159.     {
  160.         return $this->orderSupervisor;
  161.     }
  162.     public function setOrderSupervisor(?Admin $orderSupervisor): static
  163.     {
  164.         $this->orderSupervisor $orderSupervisor;
  165.         return $this;
  166.     }
  167.     public function getAccountingOfficeMailForNotification(): array
  168.     {
  169.         return $this->accountingOfficeMailForNotification;
  170.     }
  171.     public function setAccountingOfficeMailForNotification(?array $accountingOfficeMailForNotification): static
  172.     {
  173.         $this->accountingOfficeMailForNotification $accountingOfficeMailForNotification;
  174.         return $this;
  175.     }
  176.     /**
  177.      * @return Collection<int, Admin>
  178.      */
  179.     public function getManagement(): Collection
  180.     {
  181.         return $this->management;
  182.     }
  183.     public function addManagement(Admin $management): static
  184.     {
  185.         if (!$this->management->contains($management)) {
  186.             $this->management->add($management);
  187.         }
  188.         return $this;
  189.     }
  190.     public function removeManagement(Admin $management): static
  191.     {
  192.         $this->management->removeElement($management);
  193.         return $this;
  194.     }
  195. }