src/Entity/Company.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CompanyRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * @ORM\Entity(repositoryClass=CompanyRepository::class)
  10.  */
  11. class Company
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="string", length=255)
  21.      */
  22.     private $name;
  23.     /**
  24.      * @ORM\Column(type="string", length=32, nullable=true)
  25.      */
  26.     private $vat;
  27.     /**
  28.      * @ORM\Column(type="string", length=32, nullable=true)
  29.      */
  30.     private $siret;
  31.     /**
  32.      * @ORM\Column(type="string", nullable=true)
  33.      */
  34.     private $kbisFilename;
  35.     /**
  36.      * @ORM\Column(type="text", nullable=true)
  37.      */
  38.     private $comment;
  39.     /**
  40.      * @ORM\ManyToOne(targetEntity=Company::class, inversedBy="childrenCompanies")
  41.      */
  42.     private $parent;
  43.     /**
  44.      * @ORM\OneToMany(targetEntity=User::class, mappedBy="company")
  45.      */
  46.     private $users;
  47.     /**
  48.      * @ORM\ManyToOne(targetEntity=Shop::class, inversedBy="companies")
  49.      */
  50.     private $shop;
  51.     /**
  52.      * @ORM\ManyToOne(targetEntity=Address::class)
  53.      */
  54.     private $address;
  55.     /**
  56.      * @ORM\Column(type="boolean", nullable=true)
  57.      */
  58.     private $active;
  59.     /**
  60.      * @ORM\OneToMany(targetEntity=Company::class, mappedBy="parent")
  61.      */
  62.     private $childrenCompanies;
  63.     public function __construct()
  64.     {
  65.         $this->users = new ArrayCollection();
  66.         $this->childrenCompanies = new ArrayCollection();
  67.     }
  68.     public function __toString() {
  69.         return $this->getName();
  70.     }
  71.     public function getId(): ?int
  72.     {
  73.         return $this->id;
  74.     }
  75.     public function getName(): ?string
  76.     {
  77.         return $this->name;
  78.     }
  79.     public function setName(string $name): self
  80.     {
  81.         $this->name $name;
  82.         return $this;
  83.     }
  84.     public function getVat(): ?string
  85.     {
  86.         return $this->vat;
  87.     }
  88.     public function setVat(?string $vat): self
  89.     {
  90.         $this->vat $vat;
  91.         return $this;
  92.     }
  93.     public function getSiret(): ?string
  94.     {
  95.         return $this->siret;
  96.     }
  97.     public function setSiret(?string $siret): self
  98.     {
  99.         $this->siret $siret;
  100.         return $this;
  101.     }
  102.     public function getKbisFilename(): ?string
  103.     {
  104.         return $this->kbisFilename;
  105.     }
  106.     public function setKbisFilename(string $kbisFilename): self
  107.     {
  108.         $this->kbisFilename $kbisFilename;
  109.         return $this;
  110.     }
  111.     public function getComment(): ?string
  112.     {
  113.         return $this->comment;
  114.     }
  115.     public function setComment(?string $comment): self
  116.     {
  117.         $this->comment $comment;
  118.         return $this;
  119.     }
  120.     /**
  121.      * @return Collection<int, User>
  122.      */
  123.     public function getUsers(): Collection
  124.     {
  125.         return $this->users;
  126.     }
  127.     public function addUser(User $user): self
  128.     {
  129.         if (!$this->users->contains($user)) {
  130.             $this->users[] = $user;
  131.             $user->setCompany($this);
  132.         }
  133.         return $this;
  134.     }
  135.     public function removeUser(User $user): self
  136.     {
  137.         if ($this->users->removeElement($user)) {
  138.             // set the owning side to null (unless already changed)
  139.             if ($user->getCompany() === $this) {
  140.                 $user->setCompany(null);
  141.             }
  142.         }
  143.         return $this;
  144.     }
  145.     public function getShop(): ?Shop
  146.     {
  147.         return $this->shop;
  148.     }
  149.     public function setShop(?Shop $shop): self
  150.     {
  151.         $this->shop $shop;
  152.         return $this;
  153.     }
  154.     public function getAddress(): ?Address
  155.     {
  156.         return $this->address;
  157.     }
  158.     public function setAddress(?Address $address): self
  159.     {
  160.         $this->address $address;
  161.         return $this;
  162.     }
  163.     public function getParent(): ?Company
  164.     {
  165.         return $this->parent;
  166.     }
  167.     public function setParent(?Company $parent): self
  168.     {
  169.         $this->parent $parent;
  170.         return $this;
  171.     }
  172.     /**
  173.      * @return Collection<int, self>
  174.      */
  175.     public function getChildrenCompanies(): ?Collection
  176.     {
  177.         return $this->childrenCompanies;
  178.     }
  179.     public function addChildrenCompanies(self $childrenCompany): self
  180.     {
  181.         if (!$this->childrenCompanies->contains($childrenCompany)) {
  182.             $this->childrenCompanies[] = $childrenCompany;
  183.             $childrenCompany->setParent($this);
  184.         }
  185.         return $this;
  186.     }
  187.     public function removeChildrenCompanies(self $childrenCompany): self
  188.     {
  189.         if ($this->childrenCompanies->removeElement($childrenCompany)) {
  190.             // set the owning side to null (unless already changed)
  191.             if ($childrenCompany->getParent() === $this) {
  192.                 $childrenCompany->setParent(null);
  193.             }
  194.         }
  195.         return $this;
  196.     }
  197.     public function getActive():bool
  198.     {
  199.         return $this->active;
  200.     }
  201.     public function setActive(bool $active):self
  202.     {
  203.         $this->active $active;
  204.         return $this;
  205.     }
  206.     public function isActive(): ?bool
  207.     {
  208.         return $this->active;
  209.     }
  210.     public function addChildrenCompany(Company $childrenCompany): static
  211.     {
  212.         if (!$this->childrenCompanies->contains($childrenCompany)) {
  213.             $this->childrenCompanies->add($childrenCompany);
  214.             $childrenCompany->setParent($this);
  215.         }
  216.         return $this;
  217.     }
  218.     public function removeChildrenCompany(Company $childrenCompany): static
  219.     {
  220.         if ($this->childrenCompanies->removeElement($childrenCompany)) {
  221.             // set the owning side to null (unless already changed)
  222.             if ($childrenCompany->getParent() === $this) {
  223.                 $childrenCompany->setParent(null);
  224.             }
  225.         }
  226.         return $this;
  227.     }
  228. }