<?php
namespace App\Entity;
use App\Entity\TimestampableTrait;
use App\Repository\CollaborateurRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
/**
* @ORM\Entity(repositoryClass=CollaborateurRepository::class)
*/
class Collaborateur
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToMany(targetEntity=Transporteur::class, mappedBy="collaborateurs")
*/
private $transporteurs;
/**
* @ORM\OneToOne(targetEntity=User::class, inversedBy="collaborateur", cascade={"remove"})
* @ORM\JoinColumn(nullable=true)
*/
private $user;
/**
* @ORM\OneToOne(targetEntity=Client::class, inversedBy="collaborateurAccount")
* @ORM\JoinColumn(nullable=true)
*/
private $client;
/**
* @ORM\Column(type="string", length=255)
*/
private $carteId;
/**
* @ORM\Column(type="string", length=255)
*/
private $registrationNumber;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $carteVitale;
/**
* @ORM\Column(type="string", length=255)
*/
private $nationality;
/**
* @ORM\Column(type="string", length=255)
*/
private $familySituation;
/**
* @ORM\Column(type="boolean")
*/
private $functionType = false;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $service;
/**
* @ORM\ManyToOne(targetEntity=Park::class, inversedBy="collaborateurs")
*/
private $park;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $salaireBrute;
/**
* @ORM\Column(type="string", length=255)
*/
private $horaires;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $hourlyRate;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $contractType;
/**
* @ORM\Column(type="date", nullable=true)
*/
private $employementStart;
/**
* @ORM\Column(type="array")
*/
private $language = [];
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $cover;
/**
* @Assert\Image(maxSize="2M")
*/
private $fileCover;
/**
* @ORM\ManyToOne(targetEntity=Fonction::class, inversedBy="collaborateurs")
*/
private $fonction;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $token;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $confirmationToken;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $expirationToken;
/**
* @ORM\Column(type="boolean")
*/
private $agreeTerms;
/**
* @ORM\Column(type="string", length=3)
*/
private $code;
public function __construct()
{
$this->token = $this->strToken(15);
$this->transporteurs = 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;
}
/**
* @return Collection<int, Transporteur>
*/
public function getTransporteurs(): Collection
{
return $this->transporteurs;
}
public function addTransporteur(Transporteur $transporteur): self
{
if (!$this->transporteurs->contains($transporteur)) {
$this->transporteurs[] = $transporteur;
$transporteur->addCollaborateur($this);
}
return $this;
}
public function removeTransporteur(Transporteur $transporteur): self
{
if ($this->transporteurs->removeElement($transporteur)) {
$transporteur->removeCollaborateur($this);
}
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getClient(): ?Client
{
return $this->client;
}
public function setClient(?Client $client): self
{
$this->client = $client;
return $this;
}
public function getCarteId(): ?string
{
return $this->carteId;
}
public function setCarteId(string $carteId): self
{
$this->carteId = $carteId;
return $this;
}
public function getRegistrationNumber(): ?string
{
return $this->registrationNumber;
}
public function setRegistrationNumber(string $registrationNumber): self
{
$this->registrationNumber = $registrationNumber;
return $this;
}
public function getCarteVitale(): ?string
{
return $this->carteVitale;
}
public function setCarteVitale(?string $carteVitale): self
{
$this->carteVitale = $carteVitale;
return $this;
}
public function getNationality(): ?string
{
return $this->nationality;
}
public function setNationality(string $nationality): self
{
$this->nationality = $nationality;
return $this;
}
public function getFamilySituation(): ?string
{
return $this->familySituation;
}
public function setFamilySituation(string $familySituation): self
{
$this->familySituation = $familySituation;
return $this;
}
public function isFunctionType(): ?bool
{
return $this->functionType;
}
public function setFunctionType(bool $functionType): self
{
$this->functionType = $functionType;
return $this;
}
public function getService(): ?string
{
return $this->service;
}
public function setService(?string $service): self
{
$this->service = $service;
return $this;
}
public function getPark(): ?Park
{
return $this->park;
}
public function setPark(?Park $park): self
{
$this->park = $park;
return $this;
}
public function getSalaireBrute(): ?string
{
return $this->salaireBrute;
}
public function setSalaireBrute(?string $salaireBrute): self
{
$this->salaireBrute = $salaireBrute;
return $this;
}
public function getHoraires(): ?string
{
return $this->horaires;
}
public function setHoraires(string $horaires): self
{
$this->horaires = $horaires;
return $this;
}
public function getHourlyRate(): ?string
{
return $this->hourlyRate;
}
public function setHourlyRate(?string $hourlyRate): self
{
$this->hourlyRate = $hourlyRate;
return $this;
}
public function getContractType(): ?string
{
return $this->contractType;
}
public function setContractType(?string $contractType): self
{
$this->contractType = $contractType;
return $this;
}
public function getEmployementStart(): ?\DateTimeInterface
{
return $this->employementStart;
}
public function setEmployementStart(?\DateTimeInterface $employementStart): self
{
$this->employementStart = $employementStart;
return $this;
}
public function getLanguage(): ?array
{
return $this->language;
}
public function setLanguage(array $language): self
{
$this->language = $language;
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 getFonction(): ?Fonction
{
return $this->fonction;
}
public function setFonction(?Fonction $fonction): self
{
$this->fonction = $fonction;
return $this;
}
public function getToken(): ?string
{
return $this->token;
}
public function setToken(?string $token): self
{
$this->token = $token;
return $this;
}
public function getConfirmationToken(): ?string
{
return $this->confirmationToken;
}
public function setConfirmationToken(?string $confirmationToken): self
{
$this->confirmationToken = $confirmationToken;
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;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(string $code): self
{
$this->code = $code;
return $this;
}
}