<?php
namespace App\Entity;
use App\Entity\Trait\isActif;
use App\Entity\Trait\isTimestamstable;
use App\Repository\ProviderRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass=ProviderRepository::class)
* @ORM\HasLifecycleCallbacks
* @UniqueEntity("slug")
*/
class Provider
{
use isActif;
use isTimestamstable;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\Column(type="string", length=255)
*/
private $lastname_la;
/**
* @ORM\Column(type="string", length=255)
*/
private $firstname_la;
/**
* @ORM\Column(type="string", length=255)
*/
private $adress;
/**
* @ORM\Column(type="string", length=255)
*/
private $city;
/**
* @ORM\Column(type="integer")
*/
private $postal_code;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $phone;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $email;
/**
* @ORM\OneToMany(targetEntity=Collect::class, mappedBy="provider")
*/
private $collects;
/**
* @ORM\ManyToMany(targetEntity=Contract::class, mappedBy="providers")
*/
private $contracts;
/**
* @ORM\ManyToMany(targetEntity=Equipment::class, mappedBy="provider")
*/
private $equipment;
/**
* @ORM\OneToMany(targetEntity=ProviderHasEquipment::class, mappedBy="provider", cascade={"persist"})
*/
private $equipments;
/**
* @ORM\OneToMany(targetEntity=Ticket::class, mappedBy="provider")
*/
private $tickets;
/**
* @ORM\Column(type="string", length=255, unique=true)
*/
private $slug;
public function __construct()
{
$this->collects = new ArrayCollection();
$this->contracts = new ArrayCollection();
$this->equipment = new ArrayCollection();
$this->equipments = new ArrayCollection();
$this->tickets = 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 getLastnameLa(): ?string
{
return $this->lastname_la;
}
public function setLastnameLa(string $lastname_la): self
{
$this->lastname_la = $lastname_la;
return $this;
}
public function getFirstnameLa(): ?string
{
return $this->firstname_la;
}
public function setFirstnameLa(string $firstname_la): self
{
$this->firstname_la = $firstname_la;
return $this;
}
public function getAdress(): ?string
{
return $this->adress;
}
public function setAdress(string $adress): self
{
$this->adress = $adress;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(string $city): self
{
$this->city = $city;
return $this;
}
public function getPostalCode(): ?int
{
return $this->postal_code;
}
public function setPostalCode(int $postal_code): self
{
$this->postal_code = $postal_code;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
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->setProvider($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->getProvider() === $this) {
$collect->setProvider(null);
}
}
return $this;
}
/**
* @return Collection|Contract[]
*/
public function getContracts(): Collection
{
return $this->contracts;
}
public function addContract(Contract $contract): self
{
if (! $this->contracts->contains($contract)) {
$this->contracts[] = $contract;
$contract->addProvider($this);
}
return $this;
}
public function removeContract(Contract $contract): self
{
if ($this->contracts->removeElement($contract)) {
$contract->removeProvider($this);
}
return $this;
}
/**
* @return Collection|Equipment[]
*/
public function getEquipment(): Collection
{
return $this->equipment;
}
public function addEquipment(ProviderHasEquipment $equipment): self
{
if (! $this->equipments->contains($equipment)) {
$this->equipments[] = $equipment;
$equipment->setProvider($this);
}
return $this;
}
public function removeEquipment(Equipment $equipment): self
{
if ($this->equipment->removeElement($equipment)) {
$equipment->removeProvider($this);
}
return $this;
}
/**
* @return Collection|ProviderHasEquipment[]
*/
public function getEquipments(): Collection
{
return $this->equipments;
}
public function __toString(): string
{
return $this->getName();
}
/**
* @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->setProvider($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->getProvider() === $this) {
$ticket->setProvider(null);
}
}
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
}