<?php
namespace App\Entity;
use App\Entity\Traits\Owner;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Traits\Timestampable;
use App\Repository\VehicleRepository;
use Doctrine\Common\Collections\Collection;
use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Serializer\Annotation\Groups;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Core\Annotation\ApiProperty;
/**
* @Vich\Uploadable
*/
#[ORM\Entity(repositoryClass: VehicleRepository::class)]
#[ORM\HasLifecycleCallbacks]
#[ApiFilter(SearchFilter::class, properties: ['id' => 'exact', 'company' => 'exact', 'users' => 'exact'])]
/**
*
* @ApiResource(
* collectionOperations={"get"={"normalization_context"={"groups"={"Vehicle:list"}}},
* "post"={"normalization_context"={"groups"={"Vehicle:list"}}}},
* itemOperations={"get"={"normalization_context"={"groups"={"Vehicle:item","timestampable"}}},
"put"={"normalization_context"={"groups"={"Vehicle:item","timestampable"}}},
"delete"={"normalization_context"={"groups"={"Vehicle:item","timestampable"}}}},
* order={"name"="ASC"},
* paginationEnabled=false
* )
*/
class Vehicle
{
use Timestampable;
use Owner;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
#[Groups(['Vehicle:list', 'Vehicle:item','User:item'])]
private $id;
#[ORM\Column(type: 'string', length: 255)]
#[Groups(['Vehicle:list', 'Vehicle:item','User:item'])]
private $name;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['Vehicle:list', 'Vehicle:item'])]
private $make;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['Vehicle:list', 'Vehicle:item'])]
private $model;
#[ORM\Column(type: 'string', length: 10, nullable: true)]
#[Groups(['Vehicle:list', 'Vehicle:item','User:item'])]
private $registrationNumber;
#[ORM\Column(type: 'string', length: 50, nullable: true)]
#[Groups(['Vehicle:list', 'Vehicle:item'])]
private $vin;
#[ORM\Column(type: 'date', nullable: true)]
#[Groups(['Vehicle:list', 'Vehicle:item'])]
private $reviewDate;
#[ORM\Column(type: 'date', nullable: true)]
#[Groups(['Vehicle:list', 'Vehicle:item'])]
private $insuranceDate;
#[ORM\Column(type: 'string', length: 50, nullable: true)]
#[Groups(['Vehicle:list', 'Vehicle:item'])]
private $engine;
#[ORM\Column(type: 'integer', nullable: true)]
#[Groups(['Vehicle:list', 'Vehicle:item'])]
private $mileage;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['Vehicle:item'])]
private $fuelCardId;
#[ORM\Column(type: 'integer', nullable: true)]
#[Groups(['Vehicle:item'])]
private $fuelCardPin;
#[ORM\ManyToOne(targetEntity: Company::class, inversedBy: 'vehicles')]
#[ORM\JoinColumn(nullable: false)]
#[Groups(['Vehicle:list', 'Vehicle:item', 'Company:id'])]
private $company;
#[ORM\ManyToOne(targetEntity: VehicleKind::class, inversedBy: 'vehicles')]
#[ORM\JoinColumn(nullable: false)]
#[Groups(['Vehicle:list', 'Vehicle:item'])]
private $vehicleKind;
#[ORM\ManyToOne(targetEntity: UseType::class, inversedBy: 'vehicles')]
#[ORM\JoinColumn(nullable: false)]
#[Groups(['Vehicle:list', 'Vehicle:item'])]
private $useType;
#[ORM\ManyToMany(targetEntity: FuelType::class, inversedBy: 'vehicles')]
#[Groups(['Vehicle:item', 'Vehicle:list'])]
private $fuelType;
#[ORM\OneToMany(mappedBy: 'vehicle', targetEntity: Event::class, orphanRemoval: true)]
#[Groups(['Vehicle:item'])]
private $events;
#[ORM\ManyToMany(targetEntity: User::class, inversedBy: 'vehicles')]
#[Groups(['Vehicle:item'])]
private $users;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['Vehicle:list', 'Vehicle:item'])]
private $lessee;
#[ORM\ManyToOne(targetEntity: VehicleStatus::class)]
#[ORM\JoinColumn(nullable: true)]
#[Groups(['Vehicle:list', 'Vehicle:item'])]
private $status;
#[ORM\ManyToOne(targetEntity: Tyres::class)]
#[Groups(['Vehicle:list','Vehicle:item'])]
private $tirePlType;
#[ORM\ManyToOne(targetEntity: Tyres::class)]
#[Groups(['Vehicle:list','Vehicle:item'])]
private $tirePpType;
#[ORM\ManyToOne(targetEntity: Tyres::class)]
#[Groups(['Vehicle:list','Vehicle:item'])]
private $tireLlType;
#[ORM\ManyToOne(targetEntity: Tyres::class)]
#[Groups(['Vehicle:list','Vehicle:item'])]
private $tireLpType;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['Vehicle:item'])]
private $tirePlName;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['Vehicle:item'])]
private $tirePpName;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['Vehicle:item'])]
private $tireLlName;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['Vehicle:item'])]
private $tireLpName;
#[ORM\Column(type: 'integer', nullable: true)]
#[Groups(['Vehicle:item'])]
private $tirePlProduction;
#[ORM\Column(type: 'integer', nullable: true)]
#[Groups(['Vehicle:item'])]
private $tirePpProduction;
#[ORM\Column(type: 'integer', nullable: true)]
#[Groups(['Vehicle:item'])]
private $tireLlProduction;
#[ORM\Column(type: 'integer', nullable: true)]
#[Groups(['Vehicle:item'])]
private $tireLpProduction;
#[ORM\Column(type: 'integer', nullable: true)]
#[Groups(['Vehicle:item'])]
private $tirePlWidth;
#[ORM\Column(type: 'integer', nullable: true)]
#[Groups(['Vehicle:item'])]
private $tirePlRatio;
#[ORM\Column(type: 'integer', nullable: true)]
#[Groups(['Vehicle:item'])]
private $tirePlRim;
#[ORM\Column(type: 'integer', nullable: true)]
#[Groups(['Vehicle:item'])]
private $tirePpWidth;
#[ORM\Column(type: 'integer', nullable: true)]
#[Groups(['Vehicle:item'])]
private $tirePpRatio;
#[ORM\Column(type: 'integer', nullable: true)]
#[Groups(['Vehicle:item'])]
private $tirePpRim;
#[ORM\Column(type: 'integer', nullable: true)]
#[Groups(['Vehicle:item'])]
private $tireLlWidth;
#[ORM\Column(type: 'integer', nullable: true)]
#[Groups(['Vehicle:item'])]
private $tireLlRatio;
#[ORM\Column(type: 'integer', nullable: true)]
#[Groups(['Vehicle:item'])]
private $tireLlRim;
#[ORM\Column(type: 'integer', nullable: true)]
#[Groups(['Vehicle:item'])]
private $tireLpWidth;
#[ORM\Column(type: 'integer', nullable: true)]
#[Groups(['Vehicle:item'])]
private $tireLpRatio;
#[ORM\Column(type: 'integer', nullable: true)]
#[Groups(['Vehicle:item'])]
private $tireLpRim;
#[ORM\Column(type: 'date', nullable: true)]
#[Groups(['Vehicle:item'])]
private $tirePlInstallation;
#[ORM\Column(type: 'date', nullable: true)]
#[Groups(['Vehicle:item'])]
private $tirePpInstallation;
#[ORM\Column(type: 'date', nullable: true)]
#[Groups(['Vehicle:item'])]
private $tireLlInstallation;
#[ORM\Column(type: 'date', nullable: true)]
#[Groups(['Vehicle:item'])]
private $tireLpInstallation;
#[ORM\OneToMany(mappedBy: 'vehicle', targetEntity: Notification::class, orphanRemoval: true)]
#[Groups(['Vehicle:item'])]
private $notifications;
#[ORM\Column(type: 'date', nullable: true)]
#[Groups(['Vehicle:item'])]
private $gasExpiryDate;
public function __construct()
{
$this->fuelType = new ArrayCollection();
$this->events = new ArrayCollection();
$this->users = new ArrayCollection();
$this->notifications = 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 getMake(): ?string
{
return $this->make;
}
public function setMake(?string $make): self
{
$this->make = $make;
return $this;
}
public function getModel(): ?string
{
return $this->model;
}
public function setModel(?string $model): self
{
$this->model = $model;
return $this;
}
public function getRegistrationNumber(): ?string
{
return $this->registrationNumber;
}
public function setRegistrationNumber(?string $registrationNumber): self
{
$this->registrationNumber = $registrationNumber;
return $this;
}
public function getVin(): ?string
{
return $this->vin;
}
public function setVin(?string $vin): self
{
$this->vin = $vin;
return $this;
}
public function getReviewDate(): ?\DateTimeInterface
{
return $this->reviewDate;
}
public function setReviewDate(?\DateTimeInterface $reviewDate): self
{
$this->reviewDate = $reviewDate;
return $this;
}
public function getInsuranceDate(): ?\DateTimeInterface
{
return $this->insuranceDate;
}
public function setInsuranceDate(?\DateTimeInterface $insuranceDate): self
{
$this->insuranceDate = $insuranceDate;
return $this;
}
public function getEngine(): ?string
{
return $this->engine;
}
public function setEngine(?string $engine): self
{
$this->engine = $engine;
return $this;
}
public function getMileage(): ?int
{
return $this->mileage;
}
public function setMileage(?int $mileage): self
{
$this->mileage = $mileage;
return $this;
}
public function getFuelCardId(): ?string
{
return $this->fuelCardId;
}
public function setFuelCardId(?string $fuelCardId): self
{
$this->fuelCardId = $fuelCardId;
return $this;
}
public function getFuelCardPin(): ?int
{
return $this->fuelCardPin;
}
public function setFuelCardPin(?int $fuelCardPin): self
{
$this->fuelCardPin = $fuelCardPin;
return $this;
}
public function getCompany(): ?Company
{
return $this->company;
}
public function setCompany(?Company $company): self
{
$this->company = $company;
return $this;
}
public function getVehicleKind(): ?VehicleKind
{
return $this->vehicleKind;
}
public function setVehicleKind(?VehicleKind $vehicleKind): self
{
$this->vehicleKind = $vehicleKind;
return $this;
}
public function getUseType(): ?UseType
{
return $this->useType;
}
public function setUseType(?UseType $useType): self
{
$this->useType = $useType;
return $this;
}
/**
* @return Collection|FuelType[]
*/
public function getFuelType(): Collection
{
return $this->fuelType;
}
public function addFuelType(FuelType $fuelType): self
{
if (!$this->fuelType->contains($fuelType)) {
$this->fuelType[] = $fuelType;
}
return $this;
}
public function removeFuelType(FuelType $fuelType): self
{
$this->fuelType->removeElement($fuelType);
return $this;
}
/**
* @return Collection|Event[]
*/
public function getEvents(): Collection
{
return $this->events;
}
public function addEvent(Event $event): self
{
if (!$this->events->contains($event)) {
$this->events[] = $event;
$event->setVehicle($this);
}
return $this;
}
public function removeEvent(Event $event): self
{
if ($this->events->removeElement($event)) {
// set the owning side to null (unless already changed)
if ($event->getVehicle() === $this) {
$event->setVehicle(null);
}
}
return $this;
}
public function __toString(): string
{
return $this->name;
}
/**
* @return Collection|User[]
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(User $user): self
{
if (!$this->users->contains($user)) {
$this->users[] = $user;
}
return $this;
}
public function removeUser(User $user): self
{
$this->users->removeElement($user);
return $this;
}
public function getLessee(): ?string
{
return $this->lessee;
}
public function setLessee(?string $lessee): self
{
$this->lessee = $lessee;
return $this;
}
public function getStatus(): ?VehicleStatus
{
return $this->status;
}
public function setStatus(?VehicleStatus $status): self
{
$this->status = $status;
return $this;
}
public function getTyrePlType(): ?Tyres
{
return $this->tyrePlType;
}
public function setTyrePlType(?Tyres $tyrePlType): self
{
$this->tyrePlType = $tyrePlType;
return $this;
}
public function getTyrePpType(): ?Tyres
{
return $this->tyrePpType;
}
public function setTyrePpType(?Tyres $tyrePpType): self
{
$this->tyrePpType = $tyrePpType;
return $this;
}
public function getTyreLlType(): ?Tyres
{
return $this->tyreLlType;
}
public function setTyreLlType(?Tyres $tyreLlType): self
{
$this->tyreLlType = $tyreLlType;
return $this;
}
public function getTyreLpType(): ?Tyres
{
return $this->tyreLpType;
}
public function setTyreLpType(?Tyres $tyreLpType): self
{
$this->tyreLpType = $tyreLpType;
return $this;
}
public function getTirePlName(): ?string
{
return $this->tirePlName;
}
public function setTirePlName(?string $tirePlName): self
{
$this->tirePlName = $tirePlName;
return $this;
}
public function getTirePpName(): ?string
{
return $this->tirePpName;
}
public function setTirePpName(?string $tirePpName): self
{
$this->tirePpName = $tirePpName;
return $this;
}
public function getTireLlName(): ?string
{
return $this->tireLlName;
}
public function setTireLlName(?string $tireLlName): self
{
$this->tireLlName = $tireLlName;
return $this;
}
public function getTireLpName(): ?string
{
return $this->tireLpName;
}
public function setTireLpName(?string $tireLpName): self
{
$this->tireLpName = $tireLpName;
return $this;
}
public function getTirePlProduction()
{
return $this->tirePlProduction;
}
public function setTirePlProduction( $tirePlProduction): self
{
$this->tirePlProduction = $tirePlProduction;
return $this;
}
/**
* Get the value of tirePpProduction
*/
public function getTirePpProduction()
{
return $this->tirePpProduction;
}
/**
* Set the value of tirePpProduction
*/
public function setTirePpProduction($tirePpProduction): self
{
$this->tirePpProduction = $tirePpProduction;
return $this;
}
/**
* Get the value of tireLlProduction
*/
public function getTireLlProduction()
{
return $this->tireLlProduction;
}
/**
* Set the value of tireLlProduction
*/
public function setTireLlProduction($tireLlProduction): self
{
$this->tireLlProduction = $tireLlProduction;
return $this;
}
/**
* Get the value of tireLpProduction
*/
public function getTireLpProduction()
{
return $this->tireLpProduction;
}
/**
* Set the value of tireLpProduction
*
* @return self
*/
public function setTireLpProduction($tireLpProduction)
{
$this->tireLpProduction = $tireLpProduction;
return $this;
}
public function getTirePlWidth(): ?int
{
return $this->tirePlWidth;
}
public function setTirePlWidth(?int $tirePlWidth): self
{
$this->tirePlWidth = $tirePlWidth;
return $this;
}
public function getTirePlRatio(): ?int
{
return $this->tirePlRatio;
}
public function setTirePlRatio(?int $tirePlRatio): self
{
$this->tirePlRatio = $tirePlRatio;
return $this;
}
public function getTirePlRim(): ?int
{
return $this->tirePlRim;
}
public function setTirePlRim(?int $tirePlRim): self
{
$this->tirePlRim = $tirePlRim;
return $this;
}
/**
* Get the value of tirePpWidth
*/
public function getTirePpWidth()
{
return $this->tirePpWidth;
}
/**
* Set the value of tirePpWidth
*
* @return self
*/
public function setTirePpWidth($tirePpWidth)
{
$this->tirePpWidth = $tirePpWidth;
return $this;
}
/**
* Get the value of tirePpRatio
*/
public function getTirePpRatio()
{
return $this->tirePpRatio;
}
/**
* Set the value of tirePpRatio
*/
public function setTirePpRatio($tirePpRatio): self
{
$this->tirePpRatio = $tirePpRatio;
return $this;
}
/**
* Get the value of tirePpRim
*/
public function getTirePpRim()
{
return $this->tirePpRim;
}
/**
* Set the value of tirePpRim
*
* @return self
*/
public function setTirePpRim($tirePpRim)
{
$this->tirePpRim = $tirePpRim;
return $this;
}
/**
* Get the value of tireLlWidth
*/
public function getTireLlWidth()
{
return $this->tireLlWidth;
}
/**
* Set the value of tireLlWidth
*/
public function setTireLlWidth($tireLlWidth): self
{
$this->tireLlWidth = $tireLlWidth;
return $this;
}
/**
* Get the value of tireLlRatio
*/
public function getTireLlRatio()
{
return $this->tireLlRatio;
}
/**
* Set the value of tireLlRatio
*
* @return self
*/
public function setTireLlRatio($tireLlRatio)
{
$this->tireLlRatio = $tireLlRatio;
return $this;
}
/**
* Get the value of tireLlRim
*/
public function getTireLlRim()
{
return $this->tireLlRim;
}
/**
* Set the value of tireLlRim
*/
public function setTireLlRim($tireLlRim): self
{
$this->tireLlRim = $tireLlRim;
return $this;
}
/**
* Get the value of tireLpWidth
*/
public function getTireLpWidth()
{
return $this->tireLpWidth;
}
/**
* Set the value of tireLpWidth
*
* @return self
*/
public function setTireLpWidth($tireLpWidth)
{
$this->tireLpWidth = $tireLpWidth;
return $this;
}
/**
* Get the value of tireLpRatio
*/
public function getTireLpRatio()
{
return $this->tireLpRatio;
}
/**
* Set the value of tireLpRatio
*/
public function setTireLpRatio($tireLpRatio): self
{
$this->tireLpRatio = $tireLpRatio;
return $this;
}
/**
* Get the value of tireLpRim
*/
public function getTireLpRim()
{
return $this->tireLpRim;
}
/**
* Set the value of tireLpRim
*/
public function setTireLpRim($tireLpRim): self
{
$this->tireLpRim = $tireLpRim;
return $this;
}
/**
* Get the value of tireLpInstallation
*/
public function getTireLpInstallation()
{
return $this->tireLpInstallation;
}
/**
* Set the value of tireLpInstallation
*/
public function setTireLpInstallation($tireLpInstallation): self
{
$this->tireLpInstallation = $tireLpInstallation;
return $this;
}
/**
* Get the value of tireLlInstallation
*/
public function getTireLlInstallation()
{
return $this->tireLlInstallation;
}
/**
* Set the value of tireLlInstallation
*/
public function setTireLlInstallation($tireLlInstallation): self
{
$this->tireLlInstallation = $tireLlInstallation;
return $this;
}
/**
* Get the value of tirePpInstallation
*/
public function getTirePpInstallation()
{
return $this->tirePpInstallation;
}
/**
* Set the value of tirePpInstallation
*/
public function setTirePpInstallation($tirePpInstallation): self
{
$this->tirePpInstallation = $tirePpInstallation;
return $this;
}
/**
* Get the value of tirePlInstallation
*/
public function getTirePlInstallation()
{
return $this->tirePlInstallation;
}
/**
* Set the value of tirePlInstallation
*/
public function setTirePlInstallation($tirePlInstallation): self
{
$this->tirePlInstallation = $tirePlInstallation;
return $this;
}
/**
* Get the value of tirePlType
*/
public function getTirePlType()
{
return $this->tirePlType;
}
/**
* Set the value of tirePlType
*/
public function setTirePlType($tirePlType): self
{
$this->tirePlType = $tirePlType;
return $this;
}
/**
* Get the value of tirePpType
*/
public function getTirePpType()
{
return $this->tirePpType;
}
/**
* Set the value of tirePpType
*/
public function setTirePpType($tirePpType): self
{
$this->tirePpType = $tirePpType;
return $this;
}
/**
* Get the value of tireLpType
*/
public function getTireLpType()
{
return $this->tireLpType;
}
/**
* Set the value of tireLpType
*/
public function setTireLpType($tireLpType): self
{
$this->tireLpType = $tireLpType;
return $this;
}
/**
* Get the value of tireLlType
*/
public function getTireLlType()
{
return $this->tireLlType;
}
/**
* Set the value of tireLlType
*/
public function setTireLlType($tireLlType): self
{
$this->tireLlType = $tireLlType;
return $this;
}
/**
* @return Collection|Notification[]
*/
public function getNotifications(): Collection
{
return $this->notifications;
}
public function addNotification(Notification $notification): self
{
if (!$this->notifications->contains($notification)) {
$this->notifications[] = $notification;
$notification->setVehicle($this);
}
return $this;
}
public function removeNotification(Notification $notification): self
{
if ($this->notifications->removeElement($notification)) {
// set the owning side to null (unless already changed)
if ($notification->getVehicle() === $this) {
$notification->setVehicle(null);
}
}
return $this;
}
public function getGasExpiryDate(): ?\DateTimeInterface
{
return $this->gasExpiryDate;
}
public function setGasExpiryDate(?\DateTimeInterface $gasExpiryDate): self
{
$this->gasExpiryDate = $gasExpiryDate;
return $this;
}
}