<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Prestataire;
/**
* Categorie
*
* @ORM\Table(name="Categorie")
* @ORM\Entity(repositoryClass="App\Entity\CategorieRepository")
*/
class Categorie
{
public static function createWithId($id)
{
$instance = new self();
$instance->id = $id;
return $instance;
}
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255)
*/
private $nom;
/**
* @var string
*
* @ORM\Column(name="description", type="string", length=255, nullable=true)
*/
private $description;
/**
* @var int
*
* @ORM\Column(name="price", type="integer", nullable=true)
*/
private $prix;
/**
* @var int
*
* @ORM\Column(name="credits", type="integer", nullable=true)
*/
private $credits;
/**
* @var int
*
* @ORM\Column(name="ordre", type="integer")
*/
private $ordre;
/**
* @var Categorie
*
* @ORM\ManyToOne(targetEntity="Categorie")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id", nullable=true)
*/
private $parent;
/**
* @var Categorie
*
* @ORM\ManyToOne(targetEntity="Categorie")
* @ORM\JoinColumn(name="group_id", referencedColumnName="id", nullable=true)
*/
private $group;
/**
* @var Page
*
* @ORM\OneToOne(targetEntity="Page")
* @ORM\JoinColumn(name="page_id", referencedColumnName="id", nullable=true)
*/
private $page;
/**
* @var ArrayCollection
*
* @ORM\ManyToMany(targetEntity="Prestataire", mappedBy="categories")
*/
private $prestataires;
public function __construct()
{
$this->prestataires = new ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $nom
*
* @return Categorie
*/
public function setNom($nom)
{
$this->nom = $nom;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getNom()
{
return $this->nom;
}
/**
* @return Categorie
*/
public function getParent()
{
return $this->parent;
}
/**
* @param Categorie $parent
*/
public function setParent($parent)
{
$this->parent = $parent;
}
/**
* @return Page
*/
public function getPage()
{
return $this->page;
}
/**
* @param Page $page
*/
public function setPage($page)
{
$this->page = $page;
}
/**
* Add prestataires
*
* @param Prestataire $prestataire
*
* @return Categorie
*/
public function addPrestataire(Prestataire $prestataire)
{
$this->prestataires[] = $prestataire;
return $this;
}
/**
* Remove prestataires
*
* @param Prestataire $prestataire
*/
public function removePrestataire(Prestataire $prestataire)
{
$this->prestataires->removeElement($prestataire);
}
/**
* Get prestataires
*
* @return Collection
*/
public function getPrestataires()
{
return $this->prestataires;
}
/**
* Set price
*
* @param integer $prix
*
* @return Categorie
*/
public function setPrix($prix)
{
$this->prix = $prix;
return $this;
}
/**
* Get price
*
* @return integer
*/
public function getPrix()
{
return $this->prix;
}
/**
* Set credits
*
* @param integer $credits
*
* @return Categorie
*/
public function setCredits($credits)
{
$this->credits = $credits;
return $this;
}
/**
* Get credits
*
* @return integer
*/
public function getCredits()
{
return $this->credits;
}
/**
* Set ordre
*
* @param integer $ordre
*
* @return Categorie
*/
public function setOrdre($ordre)
{
$this->ordre = $ordre;
return $this;
}
/**
* Get ordre
*
* @return integer
*/
public function getOrdre()
{
return $this->ordre;
}
public function __toString()
{
return $this->nom;
}
/**
* Set group
*
* @param Categorie $group
*
* @return Categorie
*/
public function setGroup(Categorie $group)
{
$this->group = $group;
return $this;
}
public function updateGroup()
{
if ($this->parent) {
$this->group = $this->parent;
} else {
$this->group = $this;
}
}
/**
* Get group
*
* @return Categorie
*/
public function getGroup()
{
return $this->group;
}
public function getHierarchicalName()
{
return ($this->parent ? ' ' : '') . $this->nom;
}
/**
* Set description
*
* @param string $description
* @return Categorie
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
}