caisse-bliss/src/AppBundle/Entity/ProductCategory.php

122 lines
1.9 KiB
PHP
Raw Normal View History

2018-03-15 16:04:00 +01:00
<?php
2018-04-04 17:42:27 +02:00
namespace AppBundle\Entity;
2018-03-15 16:04:00 +01:00
use Doctrine\ORM\Mapping as ORM;
2018-04-04 17:42:27 +02:00
2018-03-15 16:04:00 +01:00
/**
2018-04-04 17:42:27 +02:00
* @ORM\Entity(repositoryClass="AppBundle\Repository\ProductCategoryRepository")
2018-03-15 16:04:00 +01:00
*/
class ProductCategory {
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=100)
*/
private $name;
/**
2018-03-15 16:18:06 +01:00
* @ORM\OneToMany(targetEntity="Product", mappedBy="category")
2018-03-15 16:04:00 +01:00
*/
private $products;
2018-04-05 15:05:04 +02:00
/**
* @ORM\ManyToMany(targetEntity="AppBundle\Entity\User", mappedBy="categories")
*/
private $users;
2018-04-05 17:24:43 +02:00
public function __toString() {
return $this->getName() . ' (' . count( $this->getProducts() ) . ' produits)';
}
2018-04-05 15:05:04 +02:00
/**
* @return mixed
*/
public function getUsers() {
return $this->users;
}
/**
* @param mixed $users
*/
public function setUsers( $users ) {
$this->users = $users;
}
2018-03-15 16:18:06 +01:00
/**
* @return mixed
*/
public function getProducts() {
return $this->products;
}
/**
* @param mixed $products
*/
public function setProducts( $products ) {
$this->products = $products;
}
2018-03-15 16:04:00 +01:00
/**
* @return mixed
*/
public function getId() {
return $this->id;
}
/**
* @param mixed $id
*/
public function setId( $id ) {
$this->id = $id;
}
/**
* @return mixed
*/
public function getName() {
return $this->name;
}
/**
* @param mixed $name
*/
public function setName( $name ) {
$this->name = $name;
}
2018-04-04 17:42:27 +02:00
/**
* Constructor
*/
public function __construct() {
$this->products = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Add product
*
* @param \AppBundle\Entity\Product $product
*
* @return ProductCategory
*/
public function addProduct( \AppBundle\Entity\Product $product ) {
$this->products[] = $product;
return $this;
}
/**
* Remove product
*
* @param \AppBundle\Entity\Product $product
*/
public function removeProduct( \AppBundle\Entity\Product $product ) {
$this->products->removeElement( $product );
}
2018-03-15 16:04:00 +01:00
}