<?php
namespace App\Entity;
use App\Repository\EmployeePositionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=EmployeePositionRepository::class)
*/
class EmployeePosition
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\OneToMany(targetEntity=EmployeeHistory::class, mappedBy="position", orphanRemoval=true)
*/
private $employeeHistories;
public function __construct()
{
$this->employeeHistories = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return Collection<int, EmployeeHistory>
*/
public function getEmployeeHistories(): Collection
{
return $this->employeeHistories;
}
public function addEmployeeHistory(EmployeeHistory $employeeHistory): self
{
if (!$this->employeeHistories->contains($employeeHistory)) {
$this->employeeHistories[] = $employeeHistory;
$employeeHistory->setPosition($this);
}
return $this;
}
public function removeEmployeeHistory(EmployeeHistory $employeeHistory): self
{
if ($this->employeeHistories->removeElement($employeeHistory)) {
// set the owning side to null (unless already changed)
if ($employeeHistory->getPosition() === $this) {
$employeeHistory->setPosition(null);
}
}
return $this;
}
}