src/Entity/Technician.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\TechnicianRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. /**
  10.  * @ORM\Entity(repositoryClass=TechnicianRepository::class)
  11.  */
  12. class Technician
  13. {
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      * @Groups({"installation_edit", "technician_edit", "fluid_edit"})
  19.      */
  20.     private $id;
  21.     /**
  22.      * @ORM\Column(type="string", length=255)
  23.      * @Groups({"technician_edit"})
  24.      */
  25.     private $name;
  26.     /**
  27.      * @ORM\Column(type="string", length=255)
  28.      * @Groups({"technician_edit"})
  29.      */
  30.     private $status;
  31.     /**
  32.      * @ORM\ManyToMany(targetEntity=Installation::class, mappedBy="technicians")
  33.      */
  34.     private $installations;
  35.     /**
  36.      * @ORM\OneToMany(targetEntity=Fluid::class, mappedBy="technician")
  37.      */
  38.     private $fluids;
  39.     /**
  40.      * @ORM\OneToOne(targetEntity=Truck::class, mappedBy="technician", cascade={"persist", "remove"})
  41.      * @Groups({"technician_edit"})
  42.      */
  43.     private $truck;
  44.     /**
  45.      * @ORM\Column(type="string", length=255, nullable=true)
  46.      * @Groups({"technician_edit"})
  47.      */
  48.     private $company;
  49.     public function __construct()
  50.     {
  51.         $this->installations = new ArrayCollection();
  52.         $this->fluids = new ArrayCollection();
  53.     }
  54.     public function __toString(): string
  55.     {
  56.         return $this->name;
  57.     }
  58.     public function getId(): ?int
  59.     {
  60.         return $this->id;
  61.     }
  62.     public function getName(): ?string
  63.     {
  64.         return $this->name;
  65.     }
  66.     public function setName(string $name): self
  67.     {
  68.         $this->name $name;
  69.         return $this;
  70.     }
  71.     public function getStatus(): ?string
  72.     {
  73.         return $this->status;
  74.     }
  75.     public function setStatus(string $status): self
  76.     {
  77.         $this->status $status;
  78.         return $this;
  79.     }
  80.     /**
  81.      * @return Collection<int, Installation>
  82.      */
  83.     public function getInstallations(): Collection
  84.     {
  85.         return $this->installations;
  86.     }
  87.     public function addInstallation(Installation $installation): self
  88.     {
  89.         if (!$this->installations->contains($installation)) {
  90.             $this->installations[] = $installation;
  91.             $installation->addTechnician($this);
  92.         }
  93.         return $this;
  94.     }
  95.     public function removeInstallation(Installation $installation): self
  96.     {
  97.         if ($this->installations->removeElement($installation)) {
  98.             $installation->removeTechnician($this);
  99.         }
  100.         return $this;
  101.     }
  102.     /**
  103.      * @return Collection<int, Fluid>
  104.      */
  105.     public function getFluids(): Collection
  106.     {
  107.         return $this->fluids;
  108.     }
  109.     public function addFluid(Fluid $fluid): self
  110.     {
  111.         if (!$this->fluids->contains($fluid)) {
  112.             $this->fluids[] = $fluid;
  113.             $fluid->setTechnician($this);
  114.         }
  115.         return $this;
  116.     }
  117.     public function removeFluid(Fluid $fluid): self
  118.     {
  119.         if ($this->fluids->removeElement($fluid)) {
  120.             // set the owning side to null (unless already changed)
  121.             if ($fluid->getTechnician() === $this) {
  122.                 $fluid->setTechnician(null);
  123.             }
  124.         }
  125.         return $this;
  126.     }
  127.     public function getTruck(): ?Truck
  128.     {
  129.         return $this->truck;
  130.     }
  131.     public function setTruck(?Truck $truck): self
  132.     {
  133.         // unset the owning side of the relation if necessary
  134.         if ($truck === null && $this->truck !== null) {
  135.             $this->truck->setTechnician(null);
  136.         }
  137.         // set the owning side of the relation if necessary
  138.         if ($truck !== null && $truck->getTechnician() !== $this) {
  139.             $truck->setTechnician($this);
  140.         }
  141.         $this->truck $truck;
  142.         return $this;
  143.     }
  144.     public function getCompany(): ?string
  145.     {
  146.         return $this->company;
  147.     }
  148.     public function setCompany(?string $company): self
  149.     {
  150.         $this->company $company;
  151.         return $this;
  152.     }
  153. }