<?php
namespace App\Entity;
use App\Entity\Trait\isActif;
use App\Repository\EnterpriseRepository;
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=EnterpriseRepository::class)
* @UniqueEntity("slug")
*/
class Enterprise
{
use isActif;
/**
* @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)
*/
private $country;
/**
* @ORM\Column(type="string", length=255)
*/
private $siret;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $email;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $phone;
/**
* @ORM\OneToMany(targetEntity=User::class, mappedBy="enterprise")
*/
private $users;
/**
* @ORM\OneToMany(targetEntity=Contract::class, mappedBy="enterprise")
*/
private $contracts;
/**
* @ORM\ManyToMany(targetEntity=Equipment::class, mappedBy="enterprise")
*/
private $equipment;
/**
* @ORM\OneToMany(targetEntity=EnterpriseHasEquipment::class, mappedBy="enterprise", cascade={"persist"})
*/
private $equipments;
/**
* @ORM\OneToMany(targetEntity=Ticket::class, mappedBy="enterprise")
*/
private $tickets;
/**
* @ORM\Column(type="string", length=255, unique=true)
*/
private $slug;
/**
* @ORM\OneToMany(targetEntity=Abonnement::class, mappedBy="enterprise")
*/
private $abonnements;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $stripeCustomerId;
public function __construct()
{
$this->users = new ArrayCollection();
$this->contracts = new ArrayCollection();
$this->equipment = new ArrayCollection();
$this->equipments = new ArrayCollection();
$this->tickets = new ArrayCollection();
$this->abonnements = 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 getCountry(): ?string
{
return $this->country;
}
public function setCountry(string $country): self
{
$this->country = $country;
return $this;
}
public function getSiret(): ?string
{
return $this->siret;
}
public function setSiret(string $siret): self
{
$this->siret = $siret;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): self
{
$this->phone = $phone;
return $this;
}
/**
* @return Collection|User[]
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(User $user): self
{
if (! $this->users->contains($user)) {
$this->users[] = $user;
$user->setEnterprise($this);
}
return $this;
}
public function removeUser(User $user): self
{
if ($this->users->removeElement($user)) {
// set the owning side to null (unless already changed)
if ($user->getEnterprise() === $this) {
$user->setEnterprise(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->setEnterprise($this);
}
return $this;
}
public function removeContract(Contract $contract): self
{
if ($this->contracts->removeElement($contract)) {
// set the owning side to null (unless already changed)
if ($contract->getEnterprise() === $this) {
$contract->setEnterprise(null);
}
}
return $this;
}
/**
* @return Collection|Equipment[]
*/
public function getEquipment(): Collection
{
return $this->equipment;
}
public function addEquipment(EnterpriseHasEquipment $equipment): self
{
if (! $this->equipments->contains($equipment)) {
$this->equipments[] = $equipment;
$equipment->setEnterprise($this);
}
return $this;
}
public function removeEquipment(Equipment $equipment): self
{
if ($this->equipment->removeElement($equipment)) {
$equipment->removeEnterprise($this);
}
return $this;
}
/**
* @return Collection|EnterpriseHasEquipment[]
*/
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->setEnterprise($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->getEnterprise() === $this) {
$ticket->setEnterprise(null);
}
}
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
/**
* @return Collection|Abonnement[]
*/
public function getAbonnements(): ?Collection
{
return $this->abonnements;
}
public function addAbonnement(Abonnement $abonnement): self
{
if (! $this->abonnements->contains($abonnement)) {
$this->abonnements[] = $abonnement;
$abonnement->setEnterprise($this);
}
return $this;
}
public function removeAbonnement(Abonnement $abonnement): self
{
if ($this->abonnements->removeElement($abonnement)) {
// set the owning side to null (unless already changed)
if ($abonnement->getEnterprise() === $this) {
$abonnement->setEnterprise(null);
}
}
return $this;
}
public function getStripeCustomerId(): ?string
{
return $this->stripeCustomerId;
}
public function setStripeCustomerId(?string $stripeCustomerId): self
{
$this->stripeCustomerId = $stripeCustomerId;
return $this;
}
}