<?php
namespace App\Entity;
use App\Entity\TimestampableTrait;
use App\Repository\VehicleTypeRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=VehicleTypeRepository::class)
*/
class VehicleType
{
use TimestampableTrait;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Transporteur::class, inversedBy="vehicleTypes")
* @ORM\JoinColumn(nullable=false)
*/
private $transporteur;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $image;
/**
* @Assert\Image(maxSize="2M")
*/
private $file;
/**
* @ORM\OneToMany(targetEntity=Vehicle::class, mappedBy="type")
*/
private $vehicles;
public function __construct()
{
$this->vehicles = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTransporteur(): ?Transporteur
{
return $this->transporteur;
}
public function setTransporteur(?Transporteur $transporteur): self
{
$this->transporteur = $transporteur;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
return $this;
}
public function getFile()
{
return $this->file;
}
public function setFile($file)
{
$this->file = $file;
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->setType($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->getType() === $this) {
$vehicle->setType(null);
}
}
return $this;
}
}