<?php
namespace App\Entity;
use App\Repository\VehicleGroupRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\TimestampableTrait;
/**
* @ORM\Entity(repositoryClass=VehicleGroupRepository::class)
*/
class VehicleGroup
{
use TimestampableTrait;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $description;
/**
* @ORM\ManyToOne(targetEntity=Transporteur::class, inversedBy="vehicleGroups")
* @ORM\JoinColumn(nullable=false)
*/
private $transporteur;
/**
* @ORM\OneToMany(targetEntity=Vehicle::class, mappedBy="vehicleGroup")
*/
private $vehicles;
public function __construct()
{
$this->vehicles = 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;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getTransporteur(): ?Transporteur
{
return $this->transporteur;
}
public function setTransporteur(?Transporteur $transporteur): self
{
$this->transporteur = $transporteur;
return $this;
}
/**
* @return Collection<int, Vehicle>
*/
public function getVehicles(): Collection
{
return $this->vehicles;
}
public function addVehicle(Vehicle $vehicle): self
{
if (!$this->vehicles->contains($vehicle)) {
$this->vehicles[] = $vehicle;
$vehicle->setVehicleGroup($this);
}
return $this;
}
public function removeVehicle(Vehicle $vehicle): self
{
if ($this->vehicles->removeElement($vehicle)) {
// set the owning side to null (unless already changed)
if ($vehicle->getVehicleGroup() === $this) {
$vehicle->setVehicleGroup(null);
}
}
return $this;
}
}