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@core",
  26.      * })
  27.      */
  28.     private $id;
  29.     /**
  30.      * @ORM\ManyToOne(targetEntity=Branches::class, inversedBy="branch_departments")
  31.      */
  32.     private $branch;
  33.     /**
  34.      * @ORM\Column(type="string", length=255)
  35.      * @Groups({
  36.      *      "branch.department.core",
  37.      *
  38.      *     "branch_department@ref",
  39.      *      "branch_department@core",
  40.      *  })
  41.      */
  42.     private $name;
  43.     /**
  44.      * @ORM\Column(type="string", length=255, nullable=true)
  45.      * @Groups({
  46.      *      "branch.department.core",
  47.      *
  48.      *      "branch_department@core",
  49.      *  })
  50.      */
  51.     private $description;
  52.     /**
  53.      * @ORM\OneToMany(targetEntity=ProjectOrders::class, mappedBy="branch_department")
  54.      */
  55.     private $project_orders;
  56.     /**
  57.      * @ORM\Column(type="datetime_immutable", nullable=true)
  58.      * @Groups({
  59.      *      "branch.department.core",
  60.      *
  61.      *      "branch_department@core",
  62.      *  })
  63.      */
  64.     private $created_at;
  65.     public function __construct()
  66.     {
  67.         $this->projectOrders = new ArrayCollection();
  68.     }
  69.     public function getId(): ?int
  70.     {
  71.         return $this->id;
  72.     }
  73.     public function getBranch(): ?Branches
  74.     {
  75.         return $this->branch;
  76.     }
  77.     public function setBranch(?Branches $branch): self
  78.     {
  79.         $this->branch $branch;
  80.         return $this;
  81.     }
  82.     public function getName(): ?string
  83.     {
  84.         return $this->name;
  85.     }
  86.     public function setName(string $name): self
  87.     {
  88.         $this->name $name;
  89.         return $this;
  90.     }
  91.     public function getDescription(): ?string
  92.     {
  93.         return $this->description;
  94.     }
  95.     public function setDescription(?string $description): self
  96.     {
  97.         $this->description $description;
  98.         return $this;
  99.     }
  100.     /**
  101.      * @return Collection<int, ProjectOrders>
  102.      */
  103.     public function getProjectOrders(): Collection
  104.     {
  105.         return $this->projectOrders;
  106.     }
  107.     public function addProjectOrder(ProjectOrders $projectOrder): self
  108.     {
  109.         if (!$this->projectOrders->contains($projectOrder)) {
  110.             $this->projectOrders[] = $projectOrder;
  111.             $projectOrder->setBranchDepartment($this);
  112.         }
  113.         return $this;
  114.     }
  115.     public function removeProjectOrder(ProjectOrders $projectOrder): self
  116.     {
  117.         if ($this->projectOrders->removeElement($projectOrder)) {
  118.             // set the owning side to null (unless already changed)
  119.             if ($projectOrder->getBranchDepartment() === $this) {
  120.                 $projectOrder->setBranchDepartment(null);
  121.             }
  122.         }
  123.         return $this;
  124.     }
  125.     public function getCreatedAt(): ?\DateTimeImmutable
  126.     {
  127.         return $this->created_at;
  128.     }
  129.     public function setCreatedAt(?\DateTimeImmutable $created_at): self
  130.     {
  131.         $this->created_at $created_at;
  132.         return $this;
  133.     }
  134. }