<?php
namespace App\Entity;
use App\Repository\CompanyRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Ignore;
#[ORM\Entity(repositoryClass: CompanyRepository::class)]
class Company
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $logo = null;
#[ORM\OneToMany(mappedBy: 'company', targetEntity: Shop::class)]
#[Ignore]
private Collection $shops;
public function __construct()
{
$this->shops = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function getLogo(): ?string
{
return $this->logo;
}
public function setLogo(string $logo): static
{
$this->logo = $logo;
return $this;
}
/**
* @return Collection<int, Shop>
*/
public function getShops(): Collection
{
return $this->shops;
}
public function addShop(Shop $shop): static
{
if (!$this->shops->contains($shop)) {
$this->shops->add($shop);
$shop->setCompany($this);
}
return $this;
}
public function removeShop(Shop $shop): static
{
if ($this->shops->removeElement($shop)) {
// set the owning side to null (unless already changed)
if ($shop->getCompany() === $this) {
$shop->setCompany(null);
}
}
return $this;
}
}