caisse-bliss/src/Entity/Product.php

213 lines
3.5 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
2018-04-05 15:05:04 +02:00
use AppBundle\Traits\Commentable;
use AppBundle\Traits\Sellable;
2018-03-15 16:04:00 +01:00
use Doctrine\ORM\Mapping as ORM;
/**
2018-04-04 17:42:27 +02:00
* @ORM\Entity(repositoryClass="AppBundle\Repository\ProductRepository")
2018-03-15 16:04:00 +01:00
*/
class Product {
/**
2018-04-17 13:53:29 +02:00
* @ORM\Column(name="id", type="integer")
2018-03-15 16:04:00 +01:00
* @ORM\Id
2018-04-17 13:53:29 +02:00
* @ORM\GeneratedValue(strategy="AUTO")
2018-03-15 16:04:00 +01:00
*/
private $id;
2018-04-20 09:23:44 +02:00
/**
* number of items available
* @ORM\Column(name="stock_count", type="integer")
*/
private $stockCount;
2018-03-15 16:04:00 +01:00
/**
* @ORM\Column(type="string", length=100)
*/
private $name;
/**
2018-04-20 09:40:17 +02:00
* url for image
2018-04-17 16:23:35 +02:00
* @ORM\Column(type="string", length=256, nullable=true)
*/
private $image;
2018-03-15 16:04:00 +01:00
/**
2018-03-15 16:18:06 +01:00
* @ORM\ManyToOne(targetEntity="ProductCategory", inversedBy="products")
2018-03-15 16:04:00 +01:00
*/
private $category;
2018-03-15 16:18:06 +01:00
/**
2018-04-05 15:05:04 +02:00
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\User", inversedBy="products")
2018-03-15 16:18:06 +01:00
*/
2018-04-05 15:05:04 +02:00
private $user;
2018-04-25 11:48:37 +02:00
/**
* @ORM\OneToMany(targetEntity="AppBundle\Entity\ProductSold", mappedBy="product", cascade={"remove"})
2018-04-25 11:48:37 +02:00
*/
private $productsSold;
2018-04-05 15:05:04 +02:00
use Sellable;
use Commentable;
/**
* Get id.
*
* @return int
2018-03-15 16:04:00 +01:00
*/
public function getId() {
return $this->id;
}
/**
* Set name.
*
* @param string $name
*
* @return Product
2018-03-15 16:04:00 +01:00
*/
public function setName( $name ) {
$this->name = $name;
return $this;
2018-03-15 16:04:00 +01:00
}
/**
* Get name.
*
* @return string
2018-03-15 16:04:00 +01:00
*/
public function getName() {
return $this->name;
}
/**
* Set image.
*
* @param string|null $image
*
* @return Product
2018-03-15 16:04:00 +01:00
*/
public function setImage( $image = null ) {
$this->image = $image;
return $this;
2018-03-15 16:04:00 +01:00
}
/**
* Get image.
*
* @return string|null
2018-03-15 16:04:00 +01:00
*/
public function getImage() {
return $this->image;
2018-03-15 16:04:00 +01:00
}
/**
* Set category.
*
* @param \AppBundle\Entity\ProductCategory|null $category
*
* @return Product
2018-03-15 16:04:00 +01:00
*/
public function setCategory( \AppBundle\Entity\ProductCategory $category = null ) {
$this->category = $category;
return $this;
2018-03-15 16:04:00 +01:00
}
/**
* Get category.
*
* @return \AppBundle\Entity\ProductCategory|null
2018-03-15 16:04:00 +01:00
*/
public function getCategory() {
return $this->category;
}
/**
* Set user.
*
* @param \AppBundle\Entity\User|null $user
*
* @return Product
2018-03-15 16:04:00 +01:00
*/
public function setUser( \AppBundle\Entity\User $user = null ) {
$this->user = $user;
2018-04-05 15:05:04 +02:00
return $this;
2018-04-05 15:05:04 +02:00
}
/**
* Get user.
2018-04-05 15:05:04 +02:00
*
* @return \AppBundle\Entity\User|null
2018-04-05 15:05:04 +02:00
*/
public function getUser() {
return $this->user;
2018-04-05 15:05:04 +02:00
}
2018-04-20 09:23:44 +02:00
2018-04-20 09:40:17 +02:00
/**
* Set stockCount.
*
* @param int $stockCount
*
* @return Product
*/
public function setStockCount( $stockCount ) {
$this->stockCount = $stockCount;
return $this;
}
/**
* Get stockCount.
*
* @return int
*/
public function getStockCount() {
return $this->stockCount;
}
2018-04-25 11:48:37 +02:00
/**
* Constructor
*/
public function __construct() {
$this->productsSold = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Add productsSold.
*
* @param \AppBundle\Entity\User $productsSold
*
* @return Product
*/
public function addProductsSold( \AppBundle\Entity\User $productsSold ) {
$this->productsSold[] = $productsSold;
return $this;
}
/**
* Remove productsSold.
*
* @param \AppBundle\Entity\User $productsSold
*
* @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
*/
public function removeProductsSold( \AppBundle\Entity\User $productsSold ) {
return $this->productsSold->removeElement( $productsSold );
}
/**
* Get productsSold.
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getProductsSold() {
return $this->productsSold;
}
2018-03-15 16:04:00 +01:00
}