src/Entity/Brand.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\BrandRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=BrandRepository::class)
  9.  */
  10. class Brand
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=100)
  20.      */
  21.     private $label;
  22.     /**
  23.      * @ORM\Column(type="boolean")
  24.      */
  25.     private $is_active;
  26.     /**
  27.      * @ORM\OneToMany(targetEntity=Article::class, mappedBy="brand", orphanRemoval=true)
  28.      */
  29.     private $articles;
  30.     public function __construct()
  31.     {
  32.         $this->articles = new ArrayCollection();
  33.     }
  34.     public function getId(): ?int
  35.     {
  36.         return $this->id;
  37.     }
  38.     public function getLabel(): ?string
  39.     {
  40.         return $this->label;
  41.     }
  42.     public function setLabel(string $label): self
  43.     {
  44.         $this->label $label;
  45.         return $this;
  46.     }
  47.     public function isIsActive(): ?bool
  48.     {
  49.         return $this->is_active;
  50.     }
  51.     public function setIsActive(bool $is_active): self
  52.     {
  53.         $this->is_active $is_active;
  54.         return $this;
  55.     }
  56.     /**
  57.      * @return Collection<int, Article>
  58.      */
  59.     public function getArticles(): Collection
  60.     {
  61.         return $this->articles;
  62.     }
  63.     public function addArticle(Article $article): self
  64.     {
  65.         if (!$this->articles->contains($article)) {
  66.             $this->articles[] = $article;
  67.             $article->setBrand($this);
  68.         }
  69.         return $this;
  70.     }
  71.     public function removeArticle(Article $article): self
  72.     {
  73.         if ($this->articles->removeElement($article)) {
  74.             // set the owning side to null (unless already changed)
  75.             if ($article->getBrand() === $this) {
  76.                 $article->setBrand(null);
  77.             }
  78.         }
  79.         return $this;
  80.     }
  81. }