src/Entity/PotentialCustomerCompany.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. /**
  8.  * @ORM\Entity(
  9.  *     repositoryClass="App\Repository\PotentialCustomerCompanyRepository"
  10.  * )
  11.  * @ORM\Table(
  12.  *     name="potential_customer_company",
  13.  *     options={"collate"="utf8_swedish_ci"}
  14.  * )
  15.  * @ORM\HasLifecycleCallbacks
  16.  */
  17. class PotentialCustomerCompany implements EntityInterface
  18. {
  19.     /**
  20.      * @ORM\Id
  21.      * @ORM\Column(
  22.      *     type="integer"
  23.      * )
  24.      * @ORM\GeneratedValue(
  25.      *     strategy="AUTO"
  26.      * )
  27.      *
  28.      * @var int|null
  29.      */
  30.     protected ?int $id null;
  31.     /**
  32.      * @ORM\OneToOne(
  33.      *     targetEntity="Company",
  34.      *     inversedBy="potentialCustomer",
  35.      *     cascade={"persist"}
  36.      * )
  37.      * @ORM\JoinColumn(
  38.      *     name="company_id",
  39.      *     referencedColumnName="id",
  40.      *     onDelete="SET NULL"
  41.      * )
  42.      *
  43.      * @var Company|null
  44.      */
  45.     protected $company;
  46.     /**
  47.      * @ORM\OneToMany(
  48.      *     targetEntity="PotentialCustomerCompanyContact",
  49.      *     mappedBy="company",
  50.      *     cascade={"persist","remove"},
  51.      *     orphanRemoval=true
  52.      * )
  53.      * @orm\OrderBy({"name" = "ASC"})
  54.      *
  55.      * @var Collection|PotentialCustomerCompanyContact[]
  56.      */
  57.     protected $contacts;
  58.     /**
  59.      * @ORM\Column(
  60.      *     type="string",
  61.      *     length=500
  62.      * )
  63.      *
  64.      * @var string
  65.      */
  66.     protected $name;
  67.     /**
  68.      * @ORM\Column(
  69.      *     type="string",
  70.      *     length=5000,
  71.      *     nullable=true
  72.      * )
  73.      *
  74.      * @var string|null
  75.      */
  76.     protected $notes;
  77.     public function __construct()
  78.     {
  79.         $this->contacts = new ArrayCollection();
  80.     }
  81.     /**
  82.      * @return string
  83.      */
  84.     public function __toString(): string
  85.     {
  86.         return $this->name;
  87.     }
  88.     /**
  89.      * @param PotentialCustomerCompanyContact $contact
  90.      */
  91.     public function addContact(PotentialCustomerCompanyContact $contact)
  92.     {
  93.         if (null === $this->contacts) {
  94.             $this->contacts = new ArrayCollection();
  95.         }
  96.         $contact->setCompany($this);
  97.         $this->contacts->add($contact);
  98.     }
  99.     /**
  100.      * @return Company|null
  101.      */
  102.     public function getCompany()
  103.     {
  104.         return $this->company;
  105.     }
  106.     /**
  107.      * @return PotentialCustomerCompanyContact[]|ArrayCollection|Collection
  108.      */
  109.     public function getContacts()
  110.     {
  111.         return $this->contacts;
  112.     }
  113.     /**
  114.      * @return int|null
  115.      */
  116.     public function getId(): ?int
  117.     {
  118.         return $this->id;
  119.     }
  120.     /**
  121.      * @return string
  122.      */
  123.     public function getName()
  124.     {
  125.         return $this->name;
  126.     }
  127.     /**
  128.      * @return null|string
  129.      */
  130.     public function getNotes()
  131.     {
  132.         return $this->notes;
  133.     }
  134.     /**
  135.      * @param PotentialCustomerCompanyContact $contact
  136.      */
  137.     public function removeContact(PotentialCustomerCompanyContact $contact)
  138.     {
  139.         if (null !== $this->contacts) {
  140.             $this->contacts->removeElement($contact);
  141.         }
  142.     }
  143.     /**
  144.      * @param Company|null $company
  145.      */
  146.     public function setCompany(Company $company null)
  147.     {
  148.         $this->company $company;
  149.     }
  150.     /**
  151.      * @param string $name
  152.      */
  153.     public function setName($name)
  154.     {
  155.         $this->name $name;
  156.     }
  157.     /**
  158.      * @param string|null $notes
  159.      */
  160.     public function setNotes($notes)
  161.     {
  162.         $this->notes $notes;
  163.     }
  164. }