<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Repository\CategoryRepository")
* @ORM\Table(name="category")
*
* Defines the properties of the Tag entity to represent the subcategory tags.
*
* See https://symfony.com/doc/current/doctrine.html#creating-an-entity-class
*
* @author Yonel Ceruto <yonelceruto@gmail.com>
*/
class Category {
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private ?int $id = null;
/**
* @ORM\Column(type="string")
*/
private ?string $name = null;
/**
* @ORM\Column(type="boolean")
*/
private $published;
/**
* @ORM\Column(type="string", nullable=true)
*/
private ?string $image = null;
/**
* @ORM\Column(type="string", nullable=true)
*/
private ?string $ordre = null;
/**
* @ORM\Column(type="string", nullable=true)
*/
private ?string $color = null;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $description = null;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Subcategory", mappedBy="category",orphanRemoval=true))
* @ORM\OrderBy({"id": "DESC"})
*/
private Collection $subcategories;
public function __construct() {
$this->subcategories = new ArrayCollection();
}
public function addSubcategory(Subcategory $subcategory): void {
$subcategory->setCategory($this);
if (!$this->subcategories->contains($subcategory)) {
$this->subcategories->add($subcategory);
}
}
public function removeSubcategory(Subcategory $subcategory): void {
$this->subcategories->removeElement($subcategory);
}
public function getId(): ?int {
return $this->id;
}
public function getName(): ?string {
return $this->name;
}
public function getPublished() {
return $this->published;
}
public function getImage(): ?string {
return $this->image;
}
public function getOrdre(): ?string {
return $this->ordre;
}
public function getColor(): ?string {
return $this->color;
}
public function getDescription(): ?string {
return $this->description;
}
public function getSubcategories(): Collection {
return $this->subcategories;
}
public function setId(?int $id): void {
$this->id = $id;
}
public function setName(?string $name): void {
$this->name = $name;
}
public function setPublished($published): void {
$this->published = $published;
}
public function setImage(?string $image): void {
$this->image = $image;
}
public function setOrdre(?string $ordre): void {
$this->ordre = $ordre;
}
public function setColor(?string $color): void {
$this->color = $color;
}
public function setDescription(?string $description): void {
$this->description = $description;
}
public function setSubcategories(Collection $subcategories): void {
$this->subcategories = $subcategories;
}
}