src/Entity/Company.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CompanyRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation\Ignore;
  8. #[ORM\Entity(repositoryClassCompanyRepository::class)]
  9. class Company
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\Column(length255)]
  16.     private ?string $name null;
  17.     #[ORM\Column(length255nullabletrue)]
  18.     private ?string $logo null;
  19.     #[ORM\OneToMany(mappedBy'company'targetEntityShop::class)]
  20.     #[Ignore]
  21.     private Collection $shops;
  22.     public function __construct()
  23.     {
  24.         $this->shops = new ArrayCollection();
  25.     }
  26.     public function getId(): ?int
  27.     {
  28.         return $this->id;
  29.     }
  30.     public function getName(): ?string
  31.     {
  32.         return $this->name;
  33.     }
  34.     public function setName(string $name): static
  35.     {
  36.         $this->name $name;
  37.         return $this;
  38.     }
  39.     public function getLogo(): ?string
  40.     {
  41.         return $this->logo;
  42.     }
  43.     public function setLogo(string $logo): static
  44.     {
  45.         $this->logo $logo;
  46.         return $this;
  47.     }
  48.     /**
  49.      * @return Collection<int, Shop>
  50.      */
  51.     public function getShops(): Collection
  52.     {
  53.         return $this->shops;
  54.     }
  55.     public function addShop(Shop $shop): static
  56.     {
  57.         if (!$this->shops->contains($shop)) {
  58.             $this->shops->add($shop);
  59.             $shop->setCompany($this);
  60.         }
  61.         return $this;
  62.     }
  63.     public function removeShop(Shop $shop): static
  64.     {
  65.         if ($this->shops->removeElement($shop)) {
  66.             // set the owning side to null (unless already changed)
  67.             if ($shop->getCompany() === $this) {
  68.                 $shop->setCompany(null);
  69.             }
  70.         }
  71.         return $this;
  72.     }
  73. }