getName() . ' (' . count( $this->getProducts() ) . ' produits)'; } /** * @param $userId * * @return bool */ public function hasUser( $userId ) { foreach ( $this->getUsers() as $user ) { if ( $user->getId() === $userId ) { return true; } } return false; } /** * @return mixed */ public function getUsers() { return $this->users; } /** * @param mixed $users */ public function setUsers( $users ) { $this->users = $users; } /** * @return mixed */ public function getProducts() { return $this->products; } /** * @param mixed $products */ public function setProducts( $products ) { $this->products = $products; } /** * @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; } /** * Constructor */ public function __construct() { $this->products = new \Doctrine\Common\Collections\ArrayCollection(); } /** * Add product * * @param \App\Entity\Product $product * * @return ProductCategory */ public function addProduct( \App\Entity\Product $product ) { $this->products[] = $product; return $this; } /** * Remove product * * @param \App\Entity\Product $product */ public function removeProduct( \App\Entity\Product $product ) { $this->products->removeElement( $product ); } /** * Add user * * @param \App\Entity\User $user * * @return ProductCategory */ public function addUser( \App\Entity\User $user ) { $this->users[] = $user; return $this; } /** * Remove user * * @param \App\Entity\User $user */ public function removeUser( \App\Entity\User $user ) { $this->users->removeElement( $user ); } /** * Add productsSold. * * @param \App\Entity\ProductSold $productsSold * * @return ProductCategory */ public function addProductsSold(\App\Entity\ProductSold $productsSold) { $this->productsSold[] = $productsSold; return $this; } /** * Remove productsSold. * * @param \App\Entity\ProductSold $productsSold * * @return boolean TRUE if this collection contained the specified element, FALSE otherwise. */ public function removeProductsSold(\App\Entity\ProductSold $productsSold) { return $this->productsSold->removeElement($productsSold); } /** * Get productsSold. * * @return \Doctrine\Common\Collections\Collection */ public function getProductsSold() { return $this->productsSold; } public function getAdmin(): ?Admin { return $this->admin; } public function setAdmin(?Admin $admin): static { $this->admin = $admin; return $this; } }