src/Entity/Manufacturer.php
<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\ManufacturerRepository")
*/
class Manufacturer
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=200)
*/
private $name;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Phone", mappedBy="Manufacturer")
*/
private $phones;
public function __construct()
{
$this->phones = 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;
}
/**
* @return Collection|Phone[]
*/
public function getPhones(): Collection
{
return $this->phones;
}
public function addPhone(Phone $phone): self
{
if (!$this->phones->contains($phone)) {
$this->phones[] = $phone;
$phone->setManufacturer($this);
}
return $this;
}
public function removePhone(Phone $phone): self
{
if ($this->phones->contains($phone)) {
$this->phones->removeElement($phone);
// set the owning side to null (unless already changed)
if ($phone->getManufacturer() === $this) {
$phone->setManufacturer(null);
}
}
return $this;
}
public function __toString()
{
return $this->name;
}
}