src/Entity/Training.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Symfony\Component\Serializer\Annotation\Groups;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClass'App\Repository\TrainingRepository')]
  9. class Training
  10. {
  11.     #[Groups(['LogService'])]
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column(type'integer')]
  15.     private $id;
  16.     #[Groups(['LogService'])]
  17.     #[ORM\Column(type'string'length64nullabletrue)]
  18.     private $category;
  19.     #[Groups(['LogService'])]
  20.     #[ORM\Column(type'string'length255)]
  21.     private $title;
  22.     #[Groups(['LogService'])]
  23.     #[ORM\Column(type'text'nullabletrue)]
  24.     private $description;
  25.     #[Groups(['LogService'])]
  26.     #[ORM\Column(type'smallint'nullabletrue)]
  27.     private $rating;
  28.     #[Groups(['LogService'])]
  29.     #[ORM\Column(type'text'nullabletrue)]
  30.     private $url;
  31.     #[ORM\ManyToOne(targetEntityCompany::class, inversedBy'trainings')]
  32.     #[ORM\JoinColumn(nullablefalse)]
  33.     private $company;
  34.     #[ORM\ManyToOne(targetEntityOffice::class, inversedBy'trainings')]
  35.     private $office;
  36.     #[Groups(['LogService'])]
  37.     #[ORM\ManyToOne(targetEntityUser::class)]
  38.     private $createdBy;
  39.     #[Groups(['LogService'])]
  40.     #[ORM\Column(type'datetime')]
  41.     private $createdAt;
  42.     #[Groups(['LogService'])]
  43.     #[ORM\ManyToOne(targetEntityUser::class)]
  44.     private $updatedBy;
  45.     #[Groups(['LogService'])]
  46.     #[ORM\Column(type'datetime'nullabletrue)]
  47.     private $updatedAt;
  48.     #[ORM\Column(type'boolean')]
  49.     private $isHidden false;
  50.     #[ORM\ManyToMany(targetEntityDepartment::class, inversedBy'trainings')]
  51.     private $departments;
  52.     public function __construct()
  53.     {
  54.         $this->departments = new ArrayCollection();
  55.     }
  56.     public function getId(): ?int
  57.     {
  58.         return $this->id;
  59.     }
  60.     public function getCategory(): ?string
  61.     {
  62.         return $this->category;
  63.     }
  64.     public function setCategory(?string $category): self
  65.     {
  66.         $this->category $category;
  67.         return $this;
  68.     }
  69.     public function getTitle(): ?string
  70.     {
  71.         return $this->title;
  72.     }
  73.     public function setTitle(string $title): self
  74.     {
  75.         $this->title $title;
  76.         return $this;
  77.     }
  78.     public function getDescription(): ?string
  79.     {
  80.         return $this->description;
  81.     }
  82.     public function setDescription(?string $description): self
  83.     {
  84.         $this->description $description;
  85.         return $this;
  86.     }
  87.     public function getRating(): ?int
  88.     {
  89.         return $this->rating;
  90.     }
  91.     public function setRating(?int $rating): self
  92.     {
  93.         $this->rating $rating;
  94.         return $this;
  95.     }
  96.     public function getUrl(): ?string
  97.     {
  98.         return $this->url;
  99.     }
  100.     public function setUrl(?string $url): self
  101.     {
  102.         $this->url $url;
  103.         return $this;
  104.     }
  105.     public function getCompany(): ?Company
  106.     {
  107.         return $this->company;
  108.     }
  109.     public function setCompany(?Company $company): self
  110.     {
  111.         $this->company $company;
  112.         return $this;
  113.     }
  114.     public function getOffice(): ?Office
  115.     {
  116.         return $this->office;
  117.     }
  118.     public function setOffice(?Office $office): self
  119.     {
  120.         $this->office $office;
  121.         return $this;
  122.     }
  123.     public function getCreatedBy(): ?User
  124.     {
  125.         return $this->createdBy;
  126.     }
  127.     public function setCreatedBy(?User $createdBy): self
  128.     {
  129.         $this->createdBy $createdBy;
  130.         return $this;
  131.     }
  132.     public function getCreatedAt(): ?\DateTimeInterface
  133.     {
  134.         return $this->createdAt;
  135.     }
  136.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  137.     {
  138.         $this->createdAt $createdAt;
  139.         return $this;
  140.     }
  141.     public function getUpdatedBy(): ?User
  142.     {
  143.         return $this->updatedBy;
  144.     }
  145.     public function setUpdatedBy(?User $updatedBy): self
  146.     {
  147.         $this->updatedBy $updatedBy;
  148.         return $this;
  149.     }
  150.     public function getUpdatedAt(): ?\DateTimeInterface
  151.     {
  152.         return $this->updatedAt;
  153.     }
  154.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  155.     {
  156.         $this->updatedAt $updatedAt;
  157.         return $this;
  158.     }
  159.     public function getIsHidden(): ?bool
  160.     {
  161.         return $this->isHidden;
  162.     }
  163.     public function setIsHidden(bool $isHidden): self
  164.     {
  165.         $this->isHidden $isHidden;
  166.         return $this;
  167.     }
  168.     /**
  169.      * @return Collection|Departments[]
  170.      */
  171.     public function getDepartments(): Collection
  172.     {
  173.         return $this->departments;
  174.     }
  175.     public function addDepartment(Department $departments): self
  176.     {
  177.         if (!$this->departments->contains($departments)) {
  178.             $this->departments[] = $departments;
  179.         }
  180.         return $this;
  181.     }
  182.     public function removeDepartment(Department $departments): self
  183.     {
  184.         if ($this->departments->contains($departments)) {
  185.             $this->departments->removeElement($departments);
  186.         }
  187.         return $this;
  188.     }
  189.     function departmentFilterIds()
  190.     {
  191.         $id = [];
  192.         foreach ($this->getDepartments() as $department) {
  193.             if (!in_array($department->getId(), $id))
  194.                 array_push($id$department->getId());
  195.         }
  196.         $id count($id) == $id;
  197.         return implode(' '$id);
  198.     }
  199. }