src/Entity/Department.php line 14

Open in your IDE?
  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\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. /**
  9.  * @ORM\Entity(repositoryClass=DepartmentRepository::class)
  10.  */
  11. class Department
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="string", length=255)
  21.      */
  22.     private $name "";
  23.     /**
  24.      * @ORM\ManyToOne(targetEntity=TvCompany::class, inversedBy="departments")
  25.      */
  26.     private $tvCompany null;
  27.     /**
  28.      * @ORM\Column(type="datetime")
  29.      * @Gedmo\Timestampable(on="create")
  30.      */
  31.     private $createdAt;
  32.     /**
  33.      * @ORM\OneToMany(targetEntity=TvUser::class, mappedBy="department")
  34.      */
  35.     private $tvUsers = [];
  36.     /**
  37.      * @ORM\OneToOne(targetEntity=Segmentation::class, inversedBy="department")
  38.      */
  39.     private $segmentation;
  40.     public function __construct()
  41.     {
  42.         $this->tvUsers = new ArrayCollection();
  43.     }
  44.     public function getId(): ?int
  45.     {
  46.         return $this->id;
  47.     }
  48.     public function getName(): ?string
  49.     {
  50.         return $this->name;
  51.     }
  52.     public function setName(string $name): self
  53.     {
  54.         $this->name $name;
  55.         return $this;
  56.     }
  57.     public function getTvCompany(): ?TvCompany
  58.     {
  59.         return $this->tvCompany;
  60.     }
  61.     public function setTvCompany(?TvCompany $tvCompany): self
  62.     {
  63.         $this->tvCompany $tvCompany;
  64.         return $this;
  65.     }
  66.     public function getCreatedAt(): ?\DateTimeInterface
  67.     {
  68.         return $this->createdAt;
  69.     }
  70.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  71.     {
  72.         $this->createdAt $createdAt;
  73.         return $this;
  74.     }
  75.     /**
  76.      * @return Collection|TvUser[]
  77.      */
  78.     public function getTvUsers(): Collection
  79.     {
  80.         return $this->tvUsers;
  81.     }
  82.     public function addUser(TvUser $tvUser): self
  83.     {
  84.         if (!$this->tvUsers->contains($tvUser)) {
  85.             $this->tvUsers[] = $tvUser;
  86.             $tvUser->setDepartment($this);
  87.         }
  88.         return $this;
  89.     }
  90.     public function removeUser(TvUser $tvUser): self
  91.     {
  92.         if ($this->tvUsers->removeElement($tvUser)) {
  93.             // set the owning side to null (unless already changed)
  94.             if ($tvUser->getDepartment() === $this) {
  95.                 $tvUser->setDepartment(null);
  96.             }
  97.         }
  98.         return $this;
  99.     }
  100.     public function getSegmentation(): ?Segmentation
  101.     {
  102.         return $this->segmentation;
  103.     }
  104.     public function setSegmentation(?Segmentation $segmentation): self
  105.     {
  106.         $this->segmentation $segmentation;
  107.         return $this;
  108.     }
  109. }