src/Entity/Brand.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5.  * Brands
  6.  *
  7.  * @ORM\Table(name="brands")
  8.  * @ORM\Entity(repositoryClass="App\Repository\BrandRepository")
  9.  */
  10. class Brand
  11. {
  12.     /**
  13.      * @var int
  14.      *
  15.      * @ORM\Column(name="brand_id", type="integer", nullable=false)
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue(strategy="IDENTITY")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @var string
  22.      *
  23.      * @ORM\Column(name="_id", type="string", nullable=true)
  24.      */
  25.     protected $_id;
  26.     /**
  27.      * @var string
  28.      *
  29.      * @ORM\Column(name="label", type="string", length=255, nullable=false)
  30.      */
  31.     private $label;
  32.     /**
  33.      * @var string|null
  34.      *
  35.      * @ORM\Column(name="keywordslist", type="string", length=255, nullable=true)
  36.      */
  37.     private $keywordslist;
  38.     /**
  39.      * @var string|null
  40.      *
  41.      * @ORM\Column(name="personal_note", type="string", length=255, nullable=true)
  42.      */
  43.     private $personalNote;
  44.     /**
  45.      * @var string|null
  46.      *
  47.      * @ORM\Column(name="www", type="string", length=255, nullable=true)
  48.      */
  49.     private $www;
  50.     /**
  51.      * @var string|null
  52.      *
  53.      * @ORM\Column(name="brandtags", type="string", length=255, nullable=true)
  54.      */
  55.     private $brandtags;
  56.     /**
  57.      * @var string|null
  58.      *
  59.      * @ORM\Column(name="color", type="string", length=255, nullable=true)
  60.      */
  61.     private $color;
  62.     /**
  63.      * @var \Doctrine\Common\Collections\Collection
  64.      *
  65.      * @ORM\ManyToMany(targetEntity="App\Entity\Category", inversedBy="brands")
  66.      * @ORM\JoinTable(name="brand_has_category",
  67.      *   joinColumns={
  68.      *     @ORM\JoinColumn(name="brand_id", referencedColumnName="brand_id")
  69.      *   },
  70.      *   inverseJoinColumns={
  71.      *     @ORM\JoinColumn(name="category_id", referencedColumnName="category_id")
  72.      *   }
  73.      * )
  74.      */
  75.     private $categories;
  76.     /**
  77.      * @var \Doctrine\Common\Collections\Collection
  78.      *
  79.      * @ORM\ManyToMany(targetEntity="App\Entity\Shop", mappedBy="brands")
  80.      */
  81.     private $shops;
  82.     /**
  83.      * @ORM\Column(type="string", length=255, nullable=true)
  84.      */
  85.     private $primaryCategory;
  86.     /**
  87.      * Constructor
  88.      */
  89.     public function __construct()
  90.     {
  91.         $this->categories = new \Doctrine\Common\Collections\ArrayCollection();
  92.         $this->shops = new \Doctrine\Common\Collections\ArrayCollection();
  93.     }
  94.     /************************************************************************************************************/
  95.     /****** COLLECTIONS METHODS *********************************************************************************/
  96.     /************************************************************************************************************/
  97.     /**
  98.      * @param \App\Entity\Category $category
  99.      * @return bool
  100.      */
  101.     public function addCategory(Category $category)
  102.     {
  103.         return $this->categories->add($category);
  104.     }
  105.     /**
  106.      * @param \App\Entity\Category $category
  107.      * @return mixed|null
  108.      */
  109.     public function removeCategory(Category $category)
  110.     {
  111.         return $this->categories->remove($category);
  112.     }
  113.     /**
  114.      * @param \App\Entity\Shop $shop
  115.      * @return bool
  116.      */
  117.     public function addShop(Shop $shop)
  118.     {
  119.         return $this->shops->add($shop);
  120.     }
  121.     /**
  122.      * @param \App\Entity\Shop $shop
  123.      * @return mixed|null
  124.      */
  125.     public function removeShop(Shop $shop)
  126.     {
  127.         return $this->shops->remove($shop);
  128.     }
  129.     /**
  130.      * @return \Doctrine\Common\Collections\Collection|\App\Entity\Category[]
  131.      */
  132.     public function getCategories(): \Doctrine\Common\Collections\Collection
  133.     {
  134.         return $this->categories;
  135.     }
  136.     /**
  137.      * @return \Doctrine\Common\Collections\Collection|\App\Entity\Shop[]
  138.      */
  139.     public function getShops(): \Doctrine\Common\Collections\Collection
  140.     {
  141.         return $this->shops;
  142.     }
  143.     /************************************************************************************************************/
  144.     /****** GETTERS & SETTERS ***********************************************************************************/
  145.     /************************************************************************************************************/
  146.     /**
  147.      * @return int
  148.      */
  149.     public function getId(): int
  150.     {
  151.         return $this->id;
  152.     }
  153.     /**
  154.      * @return string
  155.      */
  156.     public function getLabel(): ?string
  157.     {
  158.         return $this->label;
  159.     }
  160.     /**
  161.      * @param string $label
  162.      */
  163.     public function setLabel(string $label): void
  164.     {
  165.         $this->label $label;
  166.     }
  167.     /**
  168.      * @return string|null
  169.      */
  170.     public function getKeywordslist(): ?string
  171.     {
  172.         return $this->keywordslist;
  173.     }
  174.     /**
  175.      * @param string|null $keywordslist
  176.      */
  177.     public function setKeywordslist(?string $keywordslist): void
  178.     {
  179.         $this->keywordslist $keywordslist;
  180.     }
  181.     /**
  182.      * @return string|null
  183.      */
  184.     public function getPersonalNote(): ?string
  185.     {
  186.         return $this->personalNote;
  187.     }
  188.     /**
  189.      * @param string|null $personalNote
  190.      */
  191.     public function setPersonalNote(?string $personalNote): void
  192.     {
  193.         $this->personalNote $personalNote;
  194.     }
  195.     /**
  196.      * @return string|null
  197.      */
  198.     public function getWww(): ?string
  199.     {
  200.         return $this->www;
  201.     }
  202.     /**
  203.      * @param string|null $www
  204.      */
  205.     public function setWww(?string $www): void
  206.     {
  207.         $this->www $www;
  208.     }
  209.     /**
  210.      * @return string|null
  211.      */
  212.     public function getBrandtags(): ?string
  213.     {
  214.         return $this->brandtags;
  215.     }
  216.     /**
  217.      * @param string|null $brandtags
  218.      */
  219.     public function setBrandtags(?string $brandtags): void
  220.     {
  221.         $this->brandtags $brandtags;
  222.     }
  223.     /**
  224.      * @return string|null
  225.      */
  226.     public function getColor(): ?string
  227.     {
  228.         return $this->color;
  229.     }
  230.     /**
  231.      * @param string|null $color
  232.      */
  233.     public function setColor(?string $color): void
  234.     {
  235.         $this->color $color;
  236.     }
  237.     /**
  238.      * Return data in array. Used by REST API
  239.      *
  240.      * @return array
  241.      */
  242.     public function toArray()
  243.     {
  244.         return [
  245.             'id' => $this->getId(),
  246.             'label' => $this->getLabel(),
  247.             'keywords' => $this->getKeywordslist(),
  248.             'personal_note' => $this->getPersonalNote(),
  249.             'www' => $this->getWww(),
  250.             'brandtags' => $this->getBrandtags(),
  251.             'color' => $this->getColor(),
  252.         ];
  253.     }
  254.     /**
  255.      * @return string|null
  256.      */
  257.     public function __toString()
  258.     {
  259.         return $this->getLabel();
  260.     }
  261.     public function getPrimaryCategory(): ?string
  262.     {
  263.         return $this->primaryCategory;
  264.     }
  265.     public function setPrimaryCategory(?string $primaryCategory): self
  266.     {
  267.         $this->primaryCategory $primaryCategory;
  268.         return $this;
  269.     }
  270. }