<?php
namespace App\Entity;
use App\Entity\{User, Country};
use App\Repository\TransporteurRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
/**
* @ORM\Entity(repositoryClass=TransporteurRepository::class)
*/
class Transporteur
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\OneToOne(targetEntity=User::class, inversedBy="transporteur", cascade={"remove"})
* @ORM\JoinColumn(nullable=true)
*/
private $user;
/**
* @ORM\ManyToMany(targetEntity=Collaborateur::class, inversedBy="transporteurs")
*/
private $collaborateurs;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $aboutUs;
/**
* @ORM\Column(type="string", length=14, nullable=true)
*/
private $siret;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $socialDenomination;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $tva;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $typePersonne;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $otherFunction;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $birthday;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $birthplace;
/**
* @ORM\Column(type="string", length=20, nullable=true)
*/
private $mobilePhone;
/**
* @ORM\Column(type="string", length=20, nullable=true)
*/
private $landlinePhone;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $address;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $address1;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $postalCode;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $city;
/**
* @ORM\ManyToOne(targetEntity=Country::class, inversedBy="transporteurs")
* @ORM\JoinColumn(nullable=true)
*/
private $country;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $longitude;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $latitude;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $cover;
/**
* @Assert\Image(maxSize="2M")
*/
private $fileCover;
/**
* @ORM\OneToOne(targetEntity=PieceJustificative::class, inversedBy="transporteur", cascade={"persist", "remove"})
* @ORM\JoinColumn(nullable=true)
*/
private $pieceJustificative;
/**
* @ORM\Column(type="string", length=20, nullable=true)
*/
private $confirmationToken;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $confirmationTokenCreatedAt;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $expirationToken;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $agreeTerms;
/**
* @ORM\OneToMany(targetEntity=Park::class, mappedBy="transporteur", cascade={"remove"})
*/
private $parks;
/**
* @ORM\OneToMany(targetEntity=Brand::class, mappedBy="transporteur", cascade={"remove"})
*/
private $brands;
/**
* @ORM\OneToMany(targetEntity=VehicleType::class, mappedBy="transporteur", cascade={"remove"})
*/
private $vehicleTypes;
/**
* @ORM\OneToMany(targetEntity=VehicleGroup::class, mappedBy="transporteur", cascade={"remove"})
*/
private $vehicleGroups;
/**
* @ORM\OneToMany(targetEntity=Vehicle::class, mappedBy="transporteur", cascade={"remove"})
*/
private $vehicles;
/**
* @ORM\OneToMany(targetEntity=Acquisition::class, mappedBy="transporteur", cascade={"remove"})
*/
private $acquisitions;
/**
* @ORM\OneToMany(targetEntity=Assurance::class, mappedBy="transporteur", cascade={"remove"})
*/
private $assurances;
/**
* @ORM\OneToMany(targetEntity=ControleTechnique::class, mappedBy="transporteur", cascade={"remove"})
*/
private $controleTechniques;
/**
* @ORM\OneToMany(targetEntity=ControleTachygraphe::class, mappedBy="transporteur", cascade={"remove"})
*/
private $controleTachygraphes;
/**
* @ORM\OneToMany(targetEntity=ControleLimiteurVitesse::class, mappedBy="transporteur", cascade={"remove"})
*/
private $controleLimiteurVitesses;
/**
* @ORM\OneToMany(targetEntity=DocumentDriver::class, mappedBy="transporteur", cascade={"remove"})
*/
private $documentDrivers;
/**
* @ORM\OneToMany(targetEntity=Carburant::class, mappedBy="transporteur", cascade={"remove"})
*/
private $carburants;
/**
* @ORM\ManyToOne(targetEntity=Department::class, inversedBy="transporteurs")
*/
private $department;
/**
* @ORM\ManyToMany(targetEntity="ProfessionalType", inversedBy="transporteurs")
* @ORM\JoinTable(name="transporteur_professional_type")
*/
private $professionalType;
public function __construct()
{
$this->confirmationToken = $this->strToken(20);
$this->collaborateurs = new ArrayCollection();
$this->parks = new ArrayCollection();
$this->brands = new ArrayCollection();
$this->vehicleTypes = new ArrayCollection();
$this->vehicleGroups = new ArrayCollection();
$this->vehicles = new ArrayCollection();
$this->acquisitions = new ArrayCollection();
$this->assurances = new ArrayCollection();
$this->controleTechniques = new ArrayCollection();
$this->controleTachygraphes = new ArrayCollection();
$this->controleLimiteurVitesses = new ArrayCollection();
$this->documentDrivers = new ArrayCollection();
$this->carburants = new ArrayCollection();
$this->professionalType = new ArrayCollection();
}
public function StrToken($length)
{
$alpha = "0123456789azertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN-_";
return substr(str_shuffle(str_repeat($alpha, $length)), 0, $length);
}
public function getId(): ?int
{
return $this->id;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
/**
* @return Collection<int, Collaborateur>
*/
public function getCollaborateurs(): Collection
{
return $this->collaborateurs;
}
public function addCollaborateur(Collaborateur $collaborateur): self
{
if (!$this->collaborateurs->contains($collaborateur)) {
$this->collaborateurs[] = $collaborateur;
}
return $this;
}
public function removeCollaborateur(Collaborateur $collaborateur): self
{
$this->collaborateurs->removeElement($collaborateur);
return $this;
}
public function getAboutUs(): ?string
{
return $this->aboutUs;
}
public function setAboutUs(?string $aboutUs): self
{
$this->aboutUs = $aboutUs;
return $this;
}
public function getSiret(): ?string
{
return $this->siret;
}
public function setSiret(string $siret): self
{
$this->siret = $siret;
return $this;
}
public function getSocialDenomination(): ?string
{
return $this->socialDenomination;
}
public function setSocialDenomination(string $socialDenomination): self
{
$this->socialDenomination = $socialDenomination;
return $this;
}
public function getTva(): ?string
{
return $this->tva;
}
public function setTva(?string $tva): self
{
$this->tva = $tva;
return $this;
}
public function getTypePersonne(): ?string
{
return $this->typePersonne;
}
public function setTypePersonne(string $typePersonne): self
{
$this->typePersonne = $typePersonne;
return $this;
}
public function getOtherFunction(): ?string
{
return $this->otherFunction;
}
public function setOtherFunction(?string $otherFunction): self
{
$this->otherFunction = $otherFunction;
return $this;
}
public function getBirthday(): ?\DateTimeInterface
{
return $this->birthday;
}
public function setBirthday(\DateTimeInterface $birthday): self
{
$this->birthday = $birthday;
return $this;
}
public function getBirthplace(): ?string
{
return $this->birthplace;
}
public function setBirthplace(?string $birthplace): self
{
$this->birthplace = $birthplace;
return $this;
}
public function getMobilePhone(): ?string
{
return $this->mobilePhone;
}
public function setMobilePhone(?string $mobilePhone): self
{
$this->mobilePhone = $mobilePhone;
return $this;
}
public function getLandlinePhone(): ?string
{
return $this->landlinePhone;
}
public function setLandlinePhone(?string $landlinePhone): self
{
$this->landlinePhone = $landlinePhone;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(string $address): self
{
$this->address = $address;
return $this;
}
public function getAddress1(): ?string
{
return $this->address1;
}
public function setAddress1(?string $address1): self
{
$this->address1 = $address1;
return $this;
}
public function getPostalCode(): ?string
{
return $this->postalCode;
}
public function setPostalCode(?string $postalCode): self
{
$this->postalCode = $postalCode;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(?string $city): self
{
$this->city = $city;
return $this;
}
public function getCountry(): ?Country
{
return $this->country;
}
public function setCountry(?Country $country): self
{
$this->country = $country;
return $this;
}
public function getLongitude(): ?string
{
return $this->longitude;
}
public function setLongitude(?string $longitude): self
{
$this->longitude = $longitude;
return $this;
}
public function getLatitude(): ?string
{
return $this->latitude;
}
public function setLatitude(?string $latitude): self
{
$this->latitude = $latitude;
return $this;
}
public function getCover(): ?string
{
return $this->cover;
}
public function setCover(?string $cover): self
{
$this->cover = $cover;
return $this;
}
public function getFileCover()
{
return $this->fileCover;
}
public function setFileCover($fileCover)
{
$this->fileCover = $fileCover;
return $this;
}
public function getPieceJustificative(): ?PieceJustificative
{
return $this->pieceJustificative;
}
public function setPieceJustificative(?PieceJustificative $pieceJustificative): self
{
$this->pieceJustificative = $pieceJustificative;
return $this;
}
public function getConfirmationToken(): ?string
{
return $this->confirmationToken;
}
public function setConfirmationToken(?string $confirmationToken): self
{
$this->confirmationToken = $confirmationToken;
return $this;
}
public function getConfirmationTokenCreatedAt(): ?\DateTimeInterface
{
return $this->confirmationTokenCreatedAt;
}
public function setConfirmationTokenCreatedAt(?\DateTimeInterface $confirmationTokenCreatedAt): self
{
$this->confirmationTokenCreatedAt = $confirmationTokenCreatedAt;
return $this;
}
public function getExpirationToken(): ?string
{
return $this->expirationToken;
}
public function setExpirationToken(?string $expirationToken): self
{
$this->expirationToken = $expirationToken;
return $this;
}
public function isAgreeTerms(): ?bool
{
return $this->agreeTerms;
}
public function setAgreeTerms(bool $agreeTerms): self
{
$this->agreeTerms = $agreeTerms;
return $this;
}
/**
* @return Collection<int, Park>
*/
public function getParks(): Collection
{
return $this->parks;
}
public function addPark(Park $park): self
{
if (!$this->parks->contains($park)) {
$this->parks[] = $park;
$park->setTransporteur($this);
}
return $this;
}
public function removePark(Park $park): self
{
if ($this->parks->removeElement($park)) {
// set the owning side to null (unless already changed)
if ($park->getTransporteur() === $this) {
$park->setTransporteur(null);
}
}
return $this;
}
/**
* @return Collection<int, Brand>
*/
public function getBrands(): Collection
{
return $this->brands;
}
public function addBrand(Brand $brand): self
{
if (!$this->brands->contains($brand)) {
$this->brands[] = $brand;
$brand->setTransporteur($this);
}
return $this;
}
public function removeBrand(Brand $brand): self
{
if ($this->brands->removeElement($brand)) {
// set the owning side to null (unless already changed)
if ($brand->getTransporteur() === $this) {
$brand->setTransporteur(null);
}
}
return $this;
}
/**
* @return Collection<int, VehicleType>
*/
public function getVehicleTypes(): Collection
{
return $this->vehicleTypes;
}
public function addVehicleType(VehicleType $vehicleType): self
{
if (!$this->vehicleTypes->contains($vehicleType)) {
$this->vehicleTypes[] = $vehicleType;
$vehicleType->setTransporteur($this);
}
return $this;
}
public function removeVehicleType(VehicleType $vehicleType): self
{
if ($this->vehicleTypes->removeElement($vehicleType)) {
// set the owning side to null (unless already changed)
if ($vehicleType->getTransporteur() === $this) {
$vehicleType->setTransporteur(null);
}
}
return $this;
}
/**
* @return Collection<int, VehicleGroup>
*/
public function getVehicleGroups(): Collection
{
return $this->vehicleGroups;
}
public function addVehicleGroup(VehicleGroup $vehicleGroup): self
{
if (!$this->vehicleGroups->contains($vehicleGroup)) {
$this->vehicleGroups[] = $vehicleGroup;
$vehicleGroup->setTransporteur($this);
}
return $this;
}
public function removeVehicleGroup(VehicleGroup $vehicleGroup): self
{
if ($this->vehicleGroups->removeElement($vehicleGroup)) {
// set the owning side to null (unless already changed)
if ($vehicleGroup->getTransporteur() === $this) {
$vehicleGroup->setTransporteur(null);
}
}
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->setTransporteur($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->getTransporteur() === $this) {
$vehicle->setTransporteur(null);
}
}
return $this;
}
/**
* @return Collection<int, Acquisition>
*/
public function getAcquisitions(): Collection
{
return $this->acquisitions;
}
public function addAcquisition(Acquisition $acquisition): self
{
if (!$this->acquisitions->contains($acquisition)) {
$this->acquisitions[] = $acquisition;
$acquisition->setTransporteur($this);
}
return $this;
}
public function removeAcquisition(Acquisition $acquisition): self
{
if ($this->acquisitions->removeElement($acquisition)) {
// set the owning side to null (unless already changed)
if ($acquisition->getTransporteur() === $this) {
$acquisition->setTransporteur(null);
}
}
return $this;
}
/**
* @return Collection<int, Assurance>
*/
public function getAssurances(): Collection
{
return $this->assurances;
}
public function addAssurance(Assurance $assurance): self
{
if (!$this->assurances->contains($assurance)) {
$this->assurances[] = $assurance;
$assurance->setTransporteur($this);
}
return $this;
}
public function removeAssurance(Assurance $assurance): self
{
if ($this->assurances->removeElement($assurance)) {
// set the owning side to null (unless already changed)
if ($assurance->getTransporteur() === $this) {
$assurance->setTransporteur(null);
}
}
return $this;
}
/**
* @return Collection|Vehicles[]
*/
public function getNonArchivedVehicles()
{
return $this->vehicles->filter(function ($vehicle) {
return $vehicle->isArchive() === false;
});
}
/**
* @return Collection|Vehicles[]
*/
public function getArchivedVehicles()
{
return $this->vehicles->filter(function ($vehicle) {
return $vehicle->isArchive() === true;
});
}
/**
* @return Collection<int, ControleTechnique>
*/
public function getControleTechniques(): Collection
{
return $this->controleTechniques;
}
public function addControleTechnique(ControleTechnique $controleTechnique): self
{
if (!$this->controleTechniques->contains($controleTechnique)) {
$this->controleTechniques[] = $controleTechnique;
$controleTechnique->setTransporteur($this);
}
return $this;
}
public function removeControleTechnique(ControleTechnique $controleTechnique): self
{
if ($this->controleTechniques->removeElement($controleTechnique)) {
// set the owning side to null (unless already changed)
if ($controleTechnique->getTransporteur() === $this) {
$controleTechnique->setTransporteur(null);
}
}
return $this;
}
/**
* @return Collection<int, ControleTachygraphe>
*/
public function getControleTachygraphes(): Collection
{
return $this->controleTachygraphes;
}
public function addControleTachygraphe(ControleTachygraphe $controleTachygraphe): self
{
if (!$this->controleTachygraphes->contains($controleTachygraphe)) {
$this->controleTachygraphes[] = $controleTachygraphe;
$controleTachygraphe->setTransporteur($this);
}
return $this;
}
public function removeControleTachygraphe(ControleTachygraphe $controleTachygraphe): self
{
if ($this->controleTachygraphes->removeElement($controleTachygraphe)) {
// set the owning side to null (unless already changed)
if ($controleTachygraphe->getTransporteur() === $this) {
$controleTachygraphe->setTransporteur(null);
}
}
return $this;
}
/**
* @return Collection<int, ControleLimiteurVitesse>
*/
public function getControleLimiteurVitesses(): Collection
{
return $this->controleLimiteurVitesses;
}
public function addControleLimiteurVitess(ControleLimiteurVitesse $controleLimiteurVitess): self
{
if (!$this->controleLimiteurVitesses->contains($controleLimiteurVitess)) {
$this->controleLimiteurVitesses[] = $controleLimiteurVitess;
$controleLimiteurVitess->setTransporteur($this);
}
return $this;
}
public function removeControleLimiteurVitess(ControleLimiteurVitesse $controleLimiteurVitess): self
{
if ($this->controleLimiteurVitesses->removeElement($controleLimiteurVitess)) {
// set the owning side to null (unless already changed)
if ($controleLimiteurVitess->getTransporteur() === $this) {
$controleLimiteurVitess->setTransporteur(null);
}
}
return $this;
}
/**
* @return Collection<int, DocumentDriver>
*/
public function getDocumentDrivers(): Collection
{
return $this->documentDrivers;
}
public function addDocumentDriver(DocumentDriver $documentDriver): self
{
if (!$this->documentDrivers->contains($documentDriver)) {
$this->documentDrivers[] = $documentDriver;
$documentDriver->setTransporteur($this);
}
return $this;
}
public function removeDocumentDriver(DocumentDriver $documentDriver): self
{
if ($this->documentDrivers->removeElement($documentDriver)) {
// set the owning side to null (unless already changed)
if ($documentDriver->getTransporteur() === $this) {
$documentDriver->setTransporteur(null);
}
}
return $this;
}
/**
* @return Collection<int, Carburant>
*/
public function getCarburants(): Collection
{
return $this->carburants;
}
public function addCarburant(Carburant $carburant): self
{
if (!$this->carburants->contains($carburant)) {
$this->carburants[] = $carburant;
$carburant->setTransporteur($this);
}
return $this;
}
public function removeCarburant(Carburant $carburant): self
{
if ($this->carburants->removeElement($carburant)) {
// set the owning side to null (unless already changed)
if ($carburant->getTransporteur() === $this) {
$carburant->setTransporteur(null);
}
}
return $this;
}
public function getDepartment(): ?Department
{
return $this->department;
}
public function setDepartment(?Department $department): self
{
$this->department = $department;
return $this;
}
/**
* @return Collection<int, ProfessionalType>
*/
public function getProfessionalType(): Collection
{
return $this->professionalType;
}
public function addProfessionalType(ProfessionalType $professionalType): self
{
if (!$this->professionalType->contains($professionalType)) {
$this->professionalType[] = $professionalType;
}
return $this;
}
public function removeProfessionalType(ProfessionalType $professionalType): self
{
$this->professionalType->removeElement($professionalType);
return $this;
}
}