src/Entity/Category.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CategoryRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassCategoryRepository::class)]
  8. class Category
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id null;
  14.     #[ORM\Column(length255)]
  15.     private ?string $name null;
  16.     #[ORM\OneToMany(mappedBy'category'targetEntityBusiness::class)]
  17.     private Collection $businesses;
  18.     #[ORM\ManyToOne]
  19.     private ?Business $center null;
  20.     public function __construct()
  21.     {
  22.         $this->businesses = new ArrayCollection();
  23.     }
  24.     public function getId(): ?int
  25.     {
  26.         return $this->id;
  27.     }
  28.     public function getName(): ?string
  29.     {
  30.         return $this->name;
  31.     }
  32.     public function setName(string $name): static
  33.     {
  34.         $this->name $name;
  35.         return $this;
  36.     }
  37.     /**
  38.      * @return Collection<int, Business>
  39.      */
  40.     public function getBusinesses(): Collection
  41.     {
  42.         return $this->businesses;
  43.     }
  44.     public function addBusiness(Business $business): static
  45.     {
  46.         if (!$this->businesses->contains($business)) {
  47.             $this->businesses->add($business);
  48.             $business->setCategories($this);
  49.         }
  50.         return $this;
  51.     }
  52.     public function removeBusiness(Business $business): static
  53.     {
  54.         if ($this->businesses->removeElement($business)) {
  55.             // set the owning side to null (unless already changed)
  56.             if ($business->getCategories() === $this) {
  57.                 $business->setCategories(null);
  58.             }
  59.         }
  60.         return $this;
  61.     }
  62.     public function getCenter(): ?Business
  63.     {
  64.         return $this->center;
  65.     }
  66.     public function setCenter(?Business $center): static
  67.     {
  68.         $this->center $center;
  69.         return $this;
  70.     }
  71. }