2018-03-15 16:04:00 +01:00
|
|
|
<?php
|
|
|
|
|
2023-06-20 19:14:19 +02:00
|
|
|
namespace App\Entity;
|
2018-03-15 16:04:00 +01:00
|
|
|
|
2023-06-20 19:14:19 +02:00
|
|
|
use App\Traits\Commentable;
|
|
|
|
use App\Traits\Sellable;
|
2018-03-15 16:04:00 +01:00
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
|
|
|
|
/**
|
2023-06-20 19:14:19 +02:00
|
|
|
* @ORM\Entity(repositoryClass="App\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-05 17:09:06 +02:00
|
|
|
|
|
|
|
/**
|
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)
|
2018-04-05 17:09:06 +02:00
|
|
|
*/
|
|
|
|
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
|
|
|
/**
|
2023-06-20 19:14:19 +02:00
|
|
|
* @ORM\ManyToOne(targetEntity="App\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
|
|
|
/**
|
2023-06-20 19:14:19 +02:00
|
|
|
* @ORM\OneToMany(targetEntity="App\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;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2018-04-19 15:00:29 +02:00
|
|
|
* Get id.
|
|
|
|
*
|
|
|
|
* @return int
|
2018-03-15 16:04:00 +01:00
|
|
|
*/
|
|
|
|
public function getId() {
|
|
|
|
return $this->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-04-19 15:00:29 +02:00
|
|
|
* Set name.
|
|
|
|
*
|
|
|
|
* @param string $name
|
|
|
|
*
|
|
|
|
* @return Product
|
2018-03-15 16:04:00 +01:00
|
|
|
*/
|
2018-04-19 15:00:29 +02:00
|
|
|
public function setName( $name ) {
|
|
|
|
$this->name = $name;
|
|
|
|
|
|
|
|
return $this;
|
2018-03-15 16:04:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-04-19 15:00:29 +02:00
|
|
|
* Get name.
|
|
|
|
*
|
|
|
|
* @return string
|
2018-03-15 16:04:00 +01:00
|
|
|
*/
|
|
|
|
public function getName() {
|
|
|
|
return $this->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-04-19 15:00:29 +02:00
|
|
|
* Set image.
|
|
|
|
*
|
|
|
|
* @param string|null $image
|
|
|
|
*
|
|
|
|
* @return Product
|
2018-03-15 16:04:00 +01:00
|
|
|
*/
|
2018-04-19 15:00:29 +02:00
|
|
|
public function setImage( $image = null ) {
|
|
|
|
$this->image = $image;
|
|
|
|
|
|
|
|
return $this;
|
2018-03-15 16:04:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-04-19 15:00:29 +02:00
|
|
|
* Get image.
|
|
|
|
*
|
|
|
|
* @return string|null
|
2018-03-15 16:04:00 +01:00
|
|
|
*/
|
2018-04-19 15:00:29 +02:00
|
|
|
public function getImage() {
|
|
|
|
return $this->image;
|
2018-03-15 16:04:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-04-19 15:00:29 +02:00
|
|
|
* Set category.
|
|
|
|
*
|
2023-06-20 19:14:19 +02:00
|
|
|
* @param \App\Entity\ProductCategory|null $category
|
2018-04-19 15:00:29 +02:00
|
|
|
*
|
|
|
|
* @return Product
|
2018-03-15 16:04:00 +01:00
|
|
|
*/
|
2023-06-20 19:14:19 +02:00
|
|
|
public function setCategory( \App\Entity\ProductCategory $category = null ) {
|
2018-04-19 15:00:29 +02:00
|
|
|
$this->category = $category;
|
|
|
|
|
|
|
|
return $this;
|
2018-03-15 16:04:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-04-19 15:00:29 +02:00
|
|
|
* Get category.
|
|
|
|
*
|
2023-06-20 19:14:19 +02:00
|
|
|
* @return \App\Entity\ProductCategory|null
|
2018-03-15 16:04:00 +01:00
|
|
|
*/
|
|
|
|
public function getCategory() {
|
|
|
|
return $this->category;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-04-19 15:00:29 +02:00
|
|
|
* Set user.
|
|
|
|
*
|
2023-06-20 19:14:19 +02:00
|
|
|
* @param \App\Entity\User|null $user
|
2018-04-19 15:00:29 +02:00
|
|
|
*
|
|
|
|
* @return Product
|
2018-03-15 16:04:00 +01:00
|
|
|
*/
|
2023-06-20 19:14:19 +02:00
|
|
|
public function setUser( \App\Entity\User $user = null ) {
|
2018-04-19 15:00:29 +02:00
|
|
|
$this->user = $user;
|
2018-04-05 15:05:04 +02:00
|
|
|
|
2018-04-19 15:00:29 +02:00
|
|
|
return $this;
|
2018-04-05 15:05:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-04-19 15:00:29 +02:00
|
|
|
* Get user.
|
2018-04-05 15:05:04 +02:00
|
|
|
*
|
2023-06-20 19:14:19 +02:00
|
|
|
* @return \App\Entity\User|null
|
2018-04-05 15:05:04 +02:00
|
|
|
*/
|
2018-04-19 15:00:29 +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.
|
|
|
|
*
|
2023-06-20 19:14:19 +02:00
|
|
|
* @param \App\Entity\User $productsSold
|
2018-04-25 11:48:37 +02:00
|
|
|
*
|
|
|
|
* @return Product
|
|
|
|
*/
|
2023-06-20 19:14:19 +02:00
|
|
|
public function addProductsSold( \App\Entity\User $productsSold ) {
|
2018-04-25 11:48:37 +02:00
|
|
|
$this->productsSold[] = $productsSold;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove productsSold.
|
|
|
|
*
|
2023-06-20 19:14:19 +02:00
|
|
|
* @param \App\Entity\User $productsSold
|
2018-04-25 11:48:37 +02:00
|
|
|
*
|
|
|
|
* @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
|
|
|
|
*/
|
2023-06-20 19:14:19 +02:00
|
|
|
public function removeProductsSold( \App\Entity\User $productsSold ) {
|
2018-04-25 11:48:37 +02:00
|
|
|
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
|
|
|
}
|