<?php
namespace App\Entity;
use App\Repository\TruckRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity(repositoryClass=TruckRepository::class)
*/
class Truck
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"stock_edit", "technician_edit"})
*/
private $id;
/**
* @ORM\OneToOne(targetEntity=Technician::class, inversedBy="truck", cascade={"persist", "remove"})
* @Groups({"stock_edit"})
*/
private $technician;
/**
* @ORM\OneToMany(targetEntity=Storage::class, mappedBy="truck")
*/
private $storages;
public function __construct()
{
$this->storages = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTechnician(): ?Technician
{
return $this->technician;
}
public function setTechnician(?Technician $technician): self
{
$this->technician = $technician;
return $this;
}
/**
* @return Collection<int, Storage>
*/
public function getStorages(): Collection
{
return $this->storages;
}
public function addStorage(Storage $storage): self
{
if (!$this->storages->contains($storage)) {
$this->storages[] = $storage;
$storage->setTruck($this);
}
return $this;
}
public function removeStorage(Storage $storage): self
{
if ($this->storages->removeElement($storage)) {
// set the owning side to null (unless already changed)
if ($storage->getTruck() === $this) {
$storage->setTruck(null);
}
}
return $this;
}
}