<?php
namespace App\Entity;
use App\Repository\TechnicianRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=TechnicianRepository::class)
*/
class Technician
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"installation_edit", "technician_edit", "fluid_edit"})
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Groups({"technician_edit"})
*/
private $name;
/**
* @ORM\Column(type="string", length=255)
* @Groups({"technician_edit"})
*/
private $status;
/**
* @ORM\ManyToMany(targetEntity=Installation::class, mappedBy="technicians")
*/
private $installations;
/**
* @ORM\OneToMany(targetEntity=Fluid::class, mappedBy="technician")
*/
private $fluids;
/**
* @ORM\OneToOne(targetEntity=Truck::class, mappedBy="technician", cascade={"persist", "remove"})
* @Groups({"technician_edit"})
*/
private $truck;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"technician_edit"})
*/
private $company;
public function __construct()
{
$this->installations = new ArrayCollection();
$this->fluids = new ArrayCollection();
}
public function __toString(): string
{
return $this->name;
}
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;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(string $status): self
{
$this->status = $status;
return $this;
}
/**
* @return Collection<int, Installation>
*/
public function getInstallations(): Collection
{
return $this->installations;
}
public function addInstallation(Installation $installation): self
{
if (!$this->installations->contains($installation)) {
$this->installations[] = $installation;
$installation->addTechnician($this);
}
return $this;
}
public function removeInstallation(Installation $installation): self
{
if ($this->installations->removeElement($installation)) {
$installation->removeTechnician($this);
}
return $this;
}
/**
* @return Collection<int, Fluid>
*/
public function getFluids(): Collection
{
return $this->fluids;
}
public function addFluid(Fluid $fluid): self
{
if (!$this->fluids->contains($fluid)) {
$this->fluids[] = $fluid;
$fluid->setTechnician($this);
}
return $this;
}
public function removeFluid(Fluid $fluid): self
{
if ($this->fluids->removeElement($fluid)) {
// set the owning side to null (unless already changed)
if ($fluid->getTechnician() === $this) {
$fluid->setTechnician(null);
}
}
return $this;
}
public function getTruck(): ?Truck
{
return $this->truck;
}
public function setTruck(?Truck $truck): self
{
// unset the owning side of the relation if necessary
if ($truck === null && $this->truck !== null) {
$this->truck->setTechnician(null);
}
// set the owning side of the relation if necessary
if ($truck !== null && $truck->getTechnician() !== $this) {
$truck->setTechnician($this);
}
$this->truck = $truck;
return $this;
}
public function getCompany(): ?string
{
return $this->company;
}
public function setCompany(?string $company): self
{
$this->company = $company;
return $this;
}
}