src/Admin/Modules/Contract/Entity/ContractTasksDepartment.php line 14

  1. <?php
  2. namespace App\Admin\Modules\Contract\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Table(name="contract_tasks_department", indexes={@ORM\Index(columns={"template_name"}), @ORM\Index(columns={"department"})})
  9.  * @ORM\Entity
  10.  */
  11. class ContractTasksDepartment
  12. {
  13.     /**
  14.      * @var int
  15.      *
  16.      * @ORM\Column(type="bigint", options={"unsigned"=true}))
  17.      * @ORM\Id
  18.      * @ORM\GeneratedValue(strategy="AUTO")
  19.      */
  20.     protected $id;
  21.     
  22.     /**
  23.      * @var \App\Admin\Modules\Contract\Entity\Contract
  24.      *
  25.      * @ORM\ManyToOne(targetEntity="App\Admin\Modules\Contract\Entity\Contract", inversedBy="tasksDepartments")
  26.      * @ORM\JoinColumns({
  27.      *   @ORM\JoinColumn(name="id_contract", referencedColumnName="id", nullable=false, onDelete="CASCADE")
  28.      * })
  29.      */
  30.     private $contract;    
  31.     /**
  32.      * @var int
  33.      *
  34.      * @ORM\Column(name="department", type="smallint", nullable=false)
  35.      */
  36.     private $department;
  37.     /**
  38.      * @var \App\Admin\Modules\Contract\Entity\ContractTasksTemplate
  39.      *
  40.      * @ORM\ManyToOne(targetEntity="App\Admin\Modules\Contract\Entity\ContractTasksTemplate")
  41.      * @ORM\JoinColumns({
  42.      *   @ORM\JoinColumn(name="id_contract_tasks_template", referencedColumnName="id", nullable=true, onDelete="SET NULL")
  43.      * })
  44.      */
  45.     private $template;
  46.     /**
  47.      * @var string
  48.      *
  49.      * @ORM\Column(name="template_name", type="string", length=255, nullable=false, options={"collation"="utf8_unicode_ci"})
  50.      */
  51.     private $templateName;
  52.     
  53.     /**
  54.      * @var \App\Admin\Modules\Contract\Entity\ContractTasksDepartmentTask
  55.      *
  56.      * @ORM\OneToMany(targetEntity="App\Admin\Modules\Contract\Entity\ContractTasksDepartmentTask", mappedBy="department", cascade={"persist"}, orphanRemoval=true)
  57.      * @ORM\OrderBy({"position"="ASC"})
  58.      */
  59.     private $tasks;
  60.     public function __construct()
  61.     {
  62.         $this->tasks = new ArrayCollection();
  63.     }
  64.     public function getId(): ?string
  65.     {
  66.         return $this->id;
  67.     }
  68.     public function getDepartment(): ?int
  69.     {
  70.         return $this->department;
  71.     }
  72.     public function setDepartment(int $department): self
  73.     {
  74.         $this->department $department;
  75.         return $this;
  76.     }
  77.     public function getTemplateName(): ?string
  78.     {
  79.         return $this->templateName;
  80.     }
  81.     public function setTemplateName(string $templateName): self
  82.     {
  83.         $this->templateName $templateName;
  84.         return $this;
  85.     }
  86.     public function getContract(): ?Contract
  87.     {
  88.         return $this->contract;
  89.     }
  90.     public function setContract(?Contract $contract): self
  91.     {
  92.         $this->contract $contract;
  93.         return $this;
  94.     }
  95.     public function getTemplate(): ?ContractTasksTemplate
  96.     {
  97.         return $this->template;
  98.     }
  99.     public function setTemplate(?ContractTasksTemplate $template): self
  100.     {
  101.         $this->template $template;
  102.         return $this;
  103.     }
  104.     /**
  105.      * @return Collection<int, ContractTasksDepartmentTask>
  106.      */
  107.     public function getTasks(): Collection
  108.     {
  109.         return $this->tasks;
  110.     }
  111.     public function addTask(ContractTasksDepartmentTask $task): self
  112.     {
  113.         if (!$this->tasks->contains($task)) {
  114.             $this->tasks->add($task);
  115.             $task->setDepartment($this);
  116.         }
  117.         return $this;
  118.     }
  119.     public function removeTask(ContractTasksDepartmentTask $task): self
  120.     {
  121.         if ($this->tasks->removeElement($task)) {
  122.             // set the owning side to null (unless already changed)
  123.             if ($task->getDepartment() === $this) {
  124.                 $task->setDepartment(null);
  125.             }
  126.         }
  127.         return $this;
  128.     }    
  129. }