<?php
namespace App\Entity;
use App\Repository\CategoryRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: CategoryRepository::class)]
class Category
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\OneToMany(mappedBy: 'category', targetEntity: Business::class)]
private Collection $businesses;
#[ORM\ManyToOne]
private ?Business $center = null;
public function __construct()
{
$this->businesses = 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;
}
/**
* @return Collection<int, Business>
*/
public function getBusinesses(): Collection
{
return $this->businesses;
}
public function addBusiness(Business $business): static
{
if (!$this->businesses->contains($business)) {
$this->businesses->add($business);
$business->setCategories($this);
}
return $this;
}
public function removeBusiness(Business $business): static
{
if ($this->businesses->removeElement($business)) {
// set the owning side to null (unless already changed)
if ($business->getCategories() === $this) {
$business->setCategories(null);
}
}
return $this;
}
public function getCenter(): ?Business
{
return $this->center;
}
public function setCenter(?Business $center): static
{
$this->center = $center;
return $this;
}
}