src/Entity/ProductBrand.php line 11

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ProductBrandRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassProductBrandRepository::class)]
  8. class ProductBrand
  9. {
  10.     #[ORM\IdORM\GeneratedValueORM\Column(type'integer')]
  11.     private int $id;
  12.     #[ORM\Column(type'string'length255)]
  13.     private string $name;
  14.     #[ORM\Column(type'string'length255)]
  15.     private string $slug;
  16.     #[ORM\OneToMany(targetEntityProduct::class, mappedBy'productBrand'orphanRemovaltrue)]
  17.     private Collection $product;
  18.     #[ORM\Column]
  19.     private ?bool $is_active null;
  20.     public function __construct()
  21.     {
  22.         $this->product = 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): self
  33.     {
  34.         $this->name $name;
  35.         return $this;
  36.     }
  37.     public function getSlug(): ?string
  38.     {
  39.         return $this->slug;
  40.     }
  41.     public function setSlug(string $slug): self
  42.     {
  43.         $this->slug $slug;
  44.         return $this;
  45.     }
  46.     /**
  47.      * @return Collection|Product[]
  48.      */
  49.     public function getProduct(): Collection
  50.     {
  51.         return $this->product;
  52.     }
  53.     public function addProduct(Product $product): self
  54.     {
  55.         if (!$this->product->contains($product)) {
  56.             $this->product[] = $product;
  57.             $product->setProductBrand($this);
  58.         }
  59.         return $this;
  60.     }
  61.     public function removeProduct(Product $product): self
  62.     {
  63.         if ($this->product->removeElement($product)) {
  64.             // set the owning side to null (unless already changed)
  65.             if ($product->getProductBrand() === $this) {
  66.                 $product->setProductBrand(null);
  67.             }
  68.         }
  69.         return $this;
  70.     }
  71.     public function isIsActive(): ?bool
  72.     {
  73.         return $this->is_active;
  74.     }
  75.     public function setIsActive(bool $is_active): static
  76.     {
  77.         $this->is_active $is_active;
  78.         return $this;
  79.     }
  80. }