src/Entity/CompanyType.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Base\AbstractEntity;
  4. use App\Repository\CompanyTypeRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * @ORM\Entity(repositoryClass=CompanyTypeRepository::class)
  10.  */
  11. class CompanyType extends AbstractEntity
  12. {
  13.     //kliens
  14.     const COMPANY_TYPE_K 1;
  15.     //beszalito
  16.     const COMPANY_TYPE_B 2;
  17.     /**
  18.      * @ORM\Column(type="string", length=255)
  19.      */
  20.     private $name;
  21.     /**
  22.      * @ORM\OneToMany(targetEntity=Company::class, mappedBy="companyType")
  23.      */
  24.     private $companies;
  25.     public function __construct()
  26.     {
  27.         $this->companies = new ArrayCollection();
  28.     }
  29.     public function __toString(): string
  30.     {
  31.         return $this->getName();
  32.     }
  33.     public function getName(): ?string
  34.     {
  35.         return $this->name;
  36.     }
  37.     public function setName(string $name): self
  38.     {
  39.         $this->name $name;
  40.         return $this;
  41.     }
  42.     /**
  43.      * @return Collection<int, Company>
  44.      */
  45.     public function getCompanies(): Collection
  46.     {
  47.         return $this->companies;
  48.     }
  49.     public function addCompany(Company $company): self
  50.     {
  51.         if (!$this->companies->contains($company)) {
  52.             $this->companies[] = $company;
  53.             $company->setCompanyType($this);
  54.         }
  55.         return $this;
  56.     }
  57.     public function removeCompany(Company $company): self
  58.     {
  59.         if ($this->companies->removeElement($company)) {
  60.             // set the owning side to null (unless already changed)
  61.             if ($company->getCompanyType() === $this) {
  62.                 $company->setCompanyType(null);
  63.             }
  64.         }
  65.         return $this;
  66.     }
  67. }