<?php
namespace App\Entity;
use App\Entity\Product\ConfirmedProduct;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use Exception;
use JMS\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
/**
* ProductVariation
*
* @ORM\Table(name="malys_product_variation")
* @ORM\Entity(repositoryClass="App\Repository\ProductVariationRepository")
* @ORM\HasLifecycleCallbacks()
*/
class ProductVariation
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @Groups({"api"})
*/
private $id;
/**
* @var float
*
* @ORM\Column(name="invoiceUnitCount", type="float")
* @Assert\NotBlank()
* @Assert\GreaterThan(
* value = 0,
* message = "Le nombre d'unité de facturation dans la variation doit être supérieur à {{ value }}"
* )
* @Groups({"api"})
*/
private $invoiceUnitCount;
/**
* @var string
*
* @ORM\Column(name="choiceLabel", type="string", length=255, nullable=true)
* @Groups({"api"})
*/
private $choiceLabel;
/**
* @var int
*
* @ORM\Column(name="priority", type="integer")
* @Assert\NotBlank()
* @Assert\GreaterThan(0)
*/
private $priority;
/**
* @var ConfirmedProduct
*
* @ORM\ManyToOne(targetEntity="App\Entity\Product\ConfirmedProduct", inversedBy="variations", fetch="EAGER")
* @ORM\JoinColumn(name="product_id", referencedColumnName="id")
* @Assert\Type("App\Entity\Product\ConfirmedProduct")
*/
protected $product;
/**
* @var Unit
*
* @ORM\ManyToOne(targetEntity="Unit")
* @ORM\JoinColumn(name="unit_id", referencedColumnName="id")
* @Groups({"api"})
*/
protected $orderUnit;
/**
* @var boolean
*
* * @ORM\Column(name="disabled", type="boolean", nullable=true)
* @Groups({"api"})
*/
protected $disabled;
/**
* @var DateTime
*
* @ORM\Column(name="createdAt", type="datetime", nullable=false)
* @Groups({"api"})
*/
protected $createdAt;
/**
* @var DateTime
*
* @ORM\Column(name="updatedAt", type="datetime", nullable=true)
* @Groups({"api"})
*/
protected $updatedAt;
public function __toString()
{
return 'prod id ' . $this->product->getId();
}
public function __construct()
{
$this->enabled = true; //@todo utile ?
}
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set invoiceUnitCount
*
* @param float $invoiceUnitCount
*
* @return ProductVariation
*/
public function setInvoiceUnitCount($invoiceUnitCount)
{
$this->invoiceUnitCount = $invoiceUnitCount;
return $this;
}
/**
* Get invoiceUnitCount
*
* @return float
*/
public function getInvoiceUnitCount()
{
return $this->invoiceUnitCount;
}
/**
* Set choiceLabel
*
* @param string $choiceLabel
*
* @return ProductVariation
*/
public function setChoiceLabel($choiceLabel)
{
$this->choiceLabel = $choiceLabel;
return $this;
}
/**
* Get choiceLabel
*
* @return string
*/
public function getChoiceLabel()
{
return $this->choiceLabel;
}
/**
* Set priority
*
* @param integer $priority
*
* @return ProductVariation
*/
public function setPriority($priority)
{
$this->priority = $priority;
return $this;
}
/**
* Get priority
*
* @return int
*/
public function getPriority()
{
return $this->priority;
}
/**
* @return ConfirmedProduct
*/
public function getProduct()
{
return $this->product;
}
/**
* @param ConfirmedProduct $product
*/
public function setProduct($product)
{
$this->product = $product;
}
/**
* @return bool
*/
public function isDisabled()
{
return $this->disabled;
}
/**
* @param bool $disabled
*/
public function setDisabled($disabled)
{
$this->disabled = $disabled;
}
/**
* @return Unit
*/
public function getOrderUnit()
{
return $this->orderUnit;
}
/**
* @param Unit $orderUnit
*/
public function setOrderUnit($orderUnit)
{
$this->orderUnit = $orderUnit;
}
/**
* @return DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* @return DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* @return ProductVariation
* @ORM\PrePersist()
* @throws Exception
*/
public function setCreatedAt()
{
$this->createdAt = new DateTime();
$this->updatedAt = new DateTime();
return $this;
}
/**
* Set updatedAt
*
* @return ProductVariation
* @ORM\PreUpdate
* @throws Exception
*/
public function setUpdatedAt()
{
$this->updatedAt = new DateTime();
return $this;
}
}