<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: 'App\Repository\TrainingRepository')]
class Training
{
#[Groups(['LogService'])]
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[Groups(['LogService'])]
#[ORM\Column(type: 'string', length: 64, nullable: true)]
private $category;
#[Groups(['LogService'])]
#[ORM\Column(type: 'string', length: 255)]
private $title;
#[Groups(['LogService'])]
#[ORM\Column(type: 'text', nullable: true)]
private $description;
#[Groups(['LogService'])]
#[ORM\Column(type: 'smallint', nullable: true)]
private $rating;
#[Groups(['LogService'])]
#[ORM\Column(type: 'text', nullable: true)]
private $url;
#[ORM\ManyToOne(targetEntity: Company::class, inversedBy: 'trainings')]
#[ORM\JoinColumn(nullable: false)]
private $company;
#[ORM\ManyToOne(targetEntity: Office::class, inversedBy: 'trainings')]
private $office;
#[Groups(['LogService'])]
#[ORM\ManyToOne(targetEntity: User::class)]
private $createdBy;
#[Groups(['LogService'])]
#[ORM\Column(type: 'datetime')]
private $createdAt;
#[Groups(['LogService'])]
#[ORM\ManyToOne(targetEntity: User::class)]
private $updatedBy;
#[Groups(['LogService'])]
#[ORM\Column(type: 'datetime', nullable: true)]
private $updatedAt;
#[ORM\Column(type: 'boolean')]
private $isHidden = false;
#[ORM\ManyToMany(targetEntity: Department::class, inversedBy: 'trainings')]
private $departments;
public function __construct()
{
$this->departments = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getCategory(): ?string
{
return $this->category;
}
public function setCategory(?string $category): self
{
$this->category = $category;
return $this;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getRating(): ?int
{
return $this->rating;
}
public function setRating(?int $rating): self
{
$this->rating = $rating;
return $this;
}
public function getUrl(): ?string
{
return $this->url;
}
public function setUrl(?string $url): self
{
$this->url = $url;
return $this;
}
public function getCompany(): ?Company
{
return $this->company;
}
public function setCompany(?Company $company): self
{
$this->company = $company;
return $this;
}
public function getOffice(): ?Office
{
return $this->office;
}
public function setOffice(?Office $office): self
{
$this->office = $office;
return $this;
}
public function getCreatedBy(): ?User
{
return $this->createdBy;
}
public function setCreatedBy(?User $createdBy): self
{
$this->createdBy = $createdBy;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedBy(): ?User
{
return $this->updatedBy;
}
public function setUpdatedBy(?User $updatedBy): self
{
$this->updatedBy = $updatedBy;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getIsHidden(): ?bool
{
return $this->isHidden;
}
public function setIsHidden(bool $isHidden): self
{
$this->isHidden = $isHidden;
return $this;
}
/**
* @return Collection|Departments[]
*/
public function getDepartments(): Collection
{
return $this->departments;
}
public function addDepartment(Department $departments): self
{
if (!$this->departments->contains($departments)) {
$this->departments[] = $departments;
}
return $this;
}
public function removeDepartment(Department $departments): self
{
if ($this->departments->contains($departments)) {
$this->departments->removeElement($departments);
}
return $this;
}
function departmentFilterIds()
{
$id = [];
foreach ($this->getDepartments() as $department) {
if (!in_array($department->getId(), $id))
array_push($id, $department->getId());
}
$id = count($id) == 0 ? 0 : $id;
return implode(' ', $id);
}
}