<?php
namespace App\Entity;
use App\Repository\CompanyRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=CompanyRepository::class)
*/
class Company
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\Column(type="string", length=32, nullable=true)
*/
private $vat;
/**
* @ORM\Column(type="string", length=32, nullable=true)
*/
private $siret;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $kbisFilename;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $comment;
/**
* @ORM\ManyToOne(targetEntity=Company::class, inversedBy="childrenCompanies")
*/
private $parent;
/**
* @ORM\OneToMany(targetEntity=User::class, mappedBy="company")
*/
private $users;
/**
* @ORM\ManyToOne(targetEntity=Shop::class, inversedBy="companies")
*/
private $shop;
/**
* @ORM\ManyToOne(targetEntity=Address::class)
*/
private $address;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $active;
/**
* @ORM\OneToMany(targetEntity=Company::class, mappedBy="parent")
*/
private $childrenCompanies;
public function __construct()
{
$this->users = new ArrayCollection();
$this->childrenCompanies = new ArrayCollection();
}
public function __toString() {
return $this->getName();
}
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 getVat(): ?string
{
return $this->vat;
}
public function setVat(?string $vat): self
{
$this->vat = $vat;
return $this;
}
public function getSiret(): ?string
{
return $this->siret;
}
public function setSiret(?string $siret): self
{
$this->siret = $siret;
return $this;
}
public function getKbisFilename(): ?string
{
return $this->kbisFilename;
}
public function setKbisFilename(string $kbisFilename): self
{
$this->kbisFilename = $kbisFilename;
return $this;
}
public function getComment(): ?string
{
return $this->comment;
}
public function setComment(?string $comment): self
{
$this->comment = $comment;
return $this;
}
/**
* @return Collection<int, User>
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(User $user): self
{
if (!$this->users->contains($user)) {
$this->users[] = $user;
$user->setCompany($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->getCompany() === $this) {
$user->setCompany(null);
}
}
return $this;
}
public function getShop(): ?Shop
{
return $this->shop;
}
public function setShop(?Shop $shop): self
{
$this->shop = $shop;
return $this;
}
public function getAddress(): ?Address
{
return $this->address;
}
public function setAddress(?Address $address): self
{
$this->address = $address;
return $this;
}
public function getParent(): ?Company
{
return $this->parent;
}
public function setParent(?Company $parent): self
{
$this->parent = $parent;
return $this;
}
/**
* @return Collection<int, self>
*/
public function getChildrenCompanies(): ?Collection
{
return $this->childrenCompanies;
}
public function addChildrenCompanies(self $childrenCompany): self
{
if (!$this->childrenCompanies->contains($childrenCompany)) {
$this->childrenCompanies[] = $childrenCompany;
$childrenCompany->setParent($this);
}
return $this;
}
public function removeChildrenCompanies(self $childrenCompany): self
{
if ($this->childrenCompanies->removeElement($childrenCompany)) {
// set the owning side to null (unless already changed)
if ($childrenCompany->getParent() === $this) {
$childrenCompany->setParent(null);
}
}
return $this;
}
public function getActive():bool
{
return $this->active;
}
public function setActive(bool $active):self
{
$this->active = $active;
return $this;
}
public function isActive(): ?bool
{
return $this->active;
}
public function addChildrenCompany(Company $childrenCompany): static
{
if (!$this->childrenCompanies->contains($childrenCompany)) {
$this->childrenCompanies->add($childrenCompany);
$childrenCompany->setParent($this);
}
return $this;
}
public function removeChildrenCompany(Company $childrenCompany): static
{
if ($this->childrenCompanies->removeElement($childrenCompany)) {
// set the owning side to null (unless already changed)
if ($childrenCompany->getParent() === $this) {
$childrenCompany->setParent(null);
}
}
return $this;
}
}