<?php
namespace App\Entity;
use App\Entity\Trait\isActif;
use App\Entity\Trait\isTimestamstable;
use App\Repository\ContractRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\JoinTable;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass=ContractRepository::class)
* @ORM\HasLifecycleCallbacks
* @UniqueEntity("slug")
*/
class Contract
{
use isActif;
use isTimestamstable;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=180)
*/
private $metric;
/**
* @ORM\ManyToOne(targetEntity=Valorization::class, inversedBy="contracts")
*/
private $valorization;
/**
* @ORM\OneToMany(targetEntity=Collect::class, mappedBy="contract")
*/
private $collects;
/**
* @ORM\ManyToOne(targetEntity=Enterprise::class, inversedBy="contracts")
* @ORM\JoinColumn(nullable=false)
*/
private $enterprise;
/**
* @ORM\ManyToMany(targetEntity=Provider::class, inversedBy="contracts")
* @JoinTable(name="Contract_Has_Provider")
*/
private $providers;
/**
* @ORM\OneToMany(targetEntity=ContractHasEquipment::class, mappedBy="contract")
*/
private $equipments;
/**
* @ORM\OneToMany(targetEntity=Ticket::class, mappedBy="contract")
*/
private $tickets;
/**
* @ORM\Column(type="datetime")
*/
private $startedAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $endedAt;
/**
* @ORM\Column(type="float")
*/
private $price;
/**
* @ORM\Column(type="float")
*/
private $commission;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="contracts")
*/
private $user;
/**
* @ORM\ManyToOne(targetEntity=WasteType::class, inversedBy="contracts")
*/
private $waste;
/**
* @ORM\Column(type="string", length=255, unique=true)
*/
private $slug;
/**
* @ORM\Column(type="string", length=255)
*/
private $periodicity;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $levage;
/**
* @ORM\Column(type="string", length=4)
*/
private $currency;
public function __construct()
{
$this->collects = new ArrayCollection();
$this->providers = new ArrayCollection();
$this->equipments = new ArrayCollection();
$this->tickets = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
/**
* @return mixed
*/
public function getMetric()
{
return $this->metric;
}
/**
* @param mixed $metric
*/
public function setMetric($metric): void
{
$this->metric = $metric;
}
public function getValorization(): ?Valorization
{
return $this->valorization;
}
public function setValorization(?Valorization $valorization): self
{
$this->valorization = $valorization;
return $this;
}
/**
* @return Collection|Collect[]
*/
public function getCollects(): Collection
{
return $this->collects;
}
public function addCollect(Collect $collect): self
{
if (! $this->collects->contains($collect)) {
$this->collects[] = $collect;
$collect->setContract($this);
}
return $this;
}
public function removeCollect(Collect $collect): self
{
if ($this->collects->removeElement($collect)) {
// set the owning side to null (unless already changed)
if ($collect->getContract() === $this) {
$collect->setContract(null);
}
}
return $this;
}
public function getEnterprise(): ?Enterprise
{
return $this->enterprise;
}
public function setEnterprise(?Enterprise $enterprise): self
{
$this->enterprise = $enterprise;
return $this;
}
/**
* @return Collection|Provider[]
*/
public function getProviders(): Collection
{
return $this->providers;
}
public function addProvider(Provider $provider): self
{
if (! $this->providers->contains($provider)) {
$this->providers[] = $provider;
}
return $this;
}
public function removeProvider(Provider $provider): self
{
$this->providers->removeElement($provider);
return $this;
}
/**
* @return Collection|ContractHasEquipment[]
*/
public function getEquipments(): Collection
{
return $this->equipments;
}
public function addEquipment(ContractHasEquipment $equipment): self
{
if (! $this->equipments->contains($equipment)) {
$this->equipments[] = $equipment;
$equipment->setContract($this);
}
return $this;
}
public function removeEquipment(ContractHasEquipment $equipment): self
{
if ($this->equipments->removeElement($equipment)) {
// set the owning side to null (unless already changed)
if ($equipment->getContract() === $this) {
$equipment->setContract(null);
}
}
return $this;
}
/**
* @return Collection|Ticket[]
*/
public function getTickets(): Collection
{
return $this->tickets;
}
public function addTicket(Ticket $ticket): self
{
if (! $this->tickets->contains($ticket)) {
$this->tickets[] = $ticket;
$ticket->setContract($this);
}
return $this;
}
public function removeTicket(Ticket $ticket): self
{
if ($this->tickets->removeElement($ticket)) {
// set the owning side to null (unless already changed)
if ($ticket->getContract() === $this) {
$ticket->setContract(null);
}
}
return $this;
}
public function getStartedAt(): ?\DateTime
{
return $this->startedAt;
}
public function setStartedAt(\DateTime $startedAt): self
{
$this->startedAt = $startedAt;
return $this;
}
public function getEndedAt(): ?\DateTime
{
return $this->endedAt;
}
public function setEndedAt(?\DateTime $endedAt): self
{
$this->endedAt = $endedAt;
return $this;
}
public function getPrice(): ?float
{
return $this->price;
}
public function setPrice(float $price): self
{
$this->price = $price;
return $this;
}
public function getCommission(): ?float
{
return $this->commission;
}
public function setCommission(float $commission): self
{
$this->commission = $commission;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function __toString(): string
{
return $this->getName();
}
public function getWaste(): ?WasteType
{
return $this->waste;
}
public function setWaste(?WasteType $waste): self
{
$this->waste = $waste;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getPeriodicity(): ?string
{
return $this->periodicity;
}
public function setPeriodicity(string $periodicity): self
{
$this->periodicity = $periodicity;
return $this;
}
public function getLevage(): ?float
{
return $this->levage;
}
public function setLevage(?float $levage): self
{
$this->levage = $levage;
return $this;
}
public function getCurrency(): ?string
{
return $this->currency;
}
public function setCurrency(string $currency): self
{
$this->currency = $currency;
return $this;
}
}