src/Entity/BranchDepartments.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\BranchDepartmentsRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. use Doctrine\ORM\Mapping\UniqueConstraint;
  9. /**
  10.  * @ORM\Entity(repositoryClass=BranchDepartmentsRepository::class)
  11.  * @ORM\Table(name="branch_departments", uniqueConstraints={
  12.  *             @UniqueConstraint(name="unique_branch_departments", columns={"branch_id", "name"})
  13.  *        })
  14.  */
  15. class BranchDepartments
  16. {
  17.     /**
  18.      * @ORM\Id
  19.      * @ORM\GeneratedValue
  20.      * @ORM\Column(type="integer")
  21.      * @Groups({
  22.      *     "branch.department.core",
  23.      *     "----",
  24.      *     "branch_department@ref",
  25.      *     "branch_department@base",
  26.      *     "branch_department@core",
  27.      * })
  28.      */
  29.     private $id;
  30.     /**
  31.      * @ORM\ManyToOne(targetEntity=Branches::class, inversedBy="branch_departments")
  32.      */
  33.     private $branch;
  34.     /**
  35.      * @ORM\Column(type="string", length=255)
  36.      * @Groups({
  37.      *     "branch.department.core",
  38.      *     "----",
  39.      *     "branch_department@ref",
  40.      *     "branch_department@base",
  41.      *     "branch_department@core",
  42.      *  })
  43.      */
  44.     private $name;
  45.     /**
  46.      * @ORM\Column(type="string", length=255, nullable=true)
  47.      * @Groups({
  48.      *     "branch.department.core",
  49.      *     "----",
  50.      *     "branch_department@base",
  51.      *     "branch_department@core",
  52.      *  })
  53.      */
  54.     private $description;
  55.     /**
  56.      * @ORM\OneToMany(targetEntity=ProjectOrders::class, mappedBy="branch_department")
  57.      */
  58.     private $project_orders;
  59.     /**
  60.      * @ORM\Column(type="datetime_immutable", nullable=true)
  61.      * @Groups({
  62.      *      "branch.department.core",
  63.      *
  64.      *      "branch_department@core",
  65.      *  })
  66.      */
  67.     private $created_at;
  68.     public function __construct()
  69.     {
  70.         $this->projectOrders = new ArrayCollection();
  71.     }
  72.     public function getId(): ?int
  73.     {
  74.         return $this->id;
  75.     }
  76.     public function getBranch(): ?Branches
  77.     {
  78.         return $this->branch;
  79.     }
  80.     public function setBranch(?Branches $branch): self
  81.     {
  82.         $this->branch = $branch;
  83.         return $this;
  84.     }
  85.     public function getName(): ?string
  86.     {
  87.         return $this->name;
  88.     }
  89.     public function setName(string $name): self
  90.     {
  91.         $this->name = $name;
  92.         return $this;
  93.     }
  94.     public function getDescription(): ?string
  95.     {
  96.         return $this->description;
  97.     }
  98.     public function setDescription(?string $description): self
  99.     {
  100.         $this->description = $description;
  101.         return $this;
  102.     }
  103.     /**
  104.      * @return Collection<int, ProjectOrders>
  105.      */
  106.     public function getProjectOrders(): Collection
  107.     {
  108.         return $this->projectOrders;
  109.     }
  110.     public function addProjectOrder(ProjectOrders $projectOrder): self
  111.     {
  112.         if (!$this->projectOrders->contains($projectOrder)) {
  113.             $this->projectOrders[] = $projectOrder;
  114.             $projectOrder->setBranchDepartment($this);
  115.         }
  116.         return $this;
  117.     }
  118.     public function removeProjectOrder(ProjectOrders $projectOrder): self
  119.     {
  120.         if ($this->projectOrders->removeElement($projectOrder)) {
  121.             // set the owning side to null (unless already changed)
  122.             if ($projectOrder->getBranchDepartment() === $this) {
  123.                 $projectOrder->setBranchDepartment(null);
  124.             }
  125.         }
  126.         return $this;
  127.     }
  128.     public function getCreatedAt(): ?\DateTimeImmutable
  129.     {
  130.         return $this->created_at;
  131.     }
  132.     public function setCreatedAt(?\DateTimeImmutable $created_at): self
  133.     {
  134.         $this->created_at = $created_at;
  135.         return $this;
  136.     }
  137. }