src/Entity/ProductVariation.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Product\ConfirmedProduct;
  4. use DateTime;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Exception;
  7. use JMS\Serializer\Annotation\Groups;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. /**
  10.  * ProductVariation
  11.  *
  12.  * @ORM\Table(name="malys_product_variation")
  13.  * @ORM\Entity(repositoryClass="App\Repository\ProductVariationRepository")
  14.  * @ORM\HasLifecycleCallbacks()
  15.  */
  16. class ProductVariation
  17. {
  18.     /**
  19.      * @var int
  20.      *
  21.      * @ORM\Column(name="id", type="integer")
  22.      * @ORM\Id
  23.      * @ORM\GeneratedValue(strategy="AUTO")
  24.      * @Groups({"api"})
  25.      */
  26.     private $id;
  27.     /**
  28.      * @var float
  29.      *
  30.      * @ORM\Column(name="invoiceUnitCount", type="float")
  31.      * @Assert\NotBlank()
  32.      * @Assert\GreaterThan(
  33.      *     value = 0,
  34.      *     message = "Le nombre d'unité de facturation dans la variation doit être supérieur à {{ value }}"
  35.      *     )
  36.      * @Groups({"api"})
  37.      */
  38.     private $invoiceUnitCount;
  39.     /**
  40.      * @var string
  41.      *
  42.      * @ORM\Column(name="choiceLabel", type="string", length=255, nullable=true)
  43.      * @Groups({"api"})
  44.      */
  45.     private $choiceLabel;
  46.     /**
  47.      * @var int
  48.      *
  49.      * @ORM\Column(name="priority", type="integer")
  50.      * @Assert\NotBlank()
  51.      * @Assert\GreaterThan(0)
  52.      */
  53.     private $priority;
  54.     /**
  55.      * @var ConfirmedProduct
  56.      *
  57.      * @ORM\ManyToOne(targetEntity="App\Entity\Product\ConfirmedProduct", inversedBy="variations", fetch="EAGER")
  58.      * @ORM\JoinColumn(name="product_id", referencedColumnName="id")
  59.      * @Assert\Type("App\Entity\Product\ConfirmedProduct")
  60.      */
  61.     protected $product;
  62.     /**
  63.      * @var Unit
  64.      *
  65.      * @ORM\ManyToOne(targetEntity="Unit")
  66.      * @ORM\JoinColumn(name="unit_id", referencedColumnName="id")
  67.      * @Groups({"api"})
  68.      */
  69.     protected $orderUnit;
  70.     /**
  71.      * @var boolean
  72.      *
  73.      * * @ORM\Column(name="disabled", type="boolean", nullable=true)
  74.      * @Groups({"api"})
  75.      */
  76.     protected $disabled;
  77.     /**
  78.      * @var DateTime
  79.      *
  80.      * @ORM\Column(name="createdAt", type="datetime", nullable=false)
  81.      * @Groups({"api"})
  82.      */
  83.     protected $createdAt;
  84.     /**
  85.      * @var DateTime
  86.      *
  87.      * @ORM\Column(name="updatedAt", type="datetime", nullable=true)
  88.      * @Groups({"api"})
  89.      */
  90.     protected $updatedAt;
  91.     public function __toString()
  92.     {
  93.         return 'prod id ' $this->product->getId();
  94.     }
  95.     public function __construct()
  96.     {
  97.         $this->enabled true//@todo utile ?
  98.     }
  99.     /**
  100.      * Get id
  101.      *
  102.      * @return int
  103.      */
  104.     public function getId()
  105.     {
  106.         return $this->id;
  107.     }
  108.     /**
  109.      * Set invoiceUnitCount
  110.      *
  111.      * @param float $invoiceUnitCount
  112.      *
  113.      * @return ProductVariation
  114.      */
  115.     public function setInvoiceUnitCount($invoiceUnitCount)
  116.     {
  117.         $this->invoiceUnitCount $invoiceUnitCount;
  118.         return $this;
  119.     }
  120.     /**
  121.      * Get invoiceUnitCount
  122.      *
  123.      * @return float
  124.      */
  125.     public function getInvoiceUnitCount()
  126.     {
  127.         return $this->invoiceUnitCount;
  128.     }
  129.     /**
  130.      * Set choiceLabel
  131.      *
  132.      * @param string $choiceLabel
  133.      *
  134.      * @return ProductVariation
  135.      */
  136.     public function setChoiceLabel($choiceLabel)
  137.     {
  138.         $this->choiceLabel $choiceLabel;
  139.         return $this;
  140.     }
  141.     /**
  142.      * Get choiceLabel
  143.      *
  144.      * @return string
  145.      */
  146.     public function getChoiceLabel()
  147.     {
  148.         return $this->choiceLabel;
  149.     }
  150.     /**
  151.      * Set priority
  152.      *
  153.      * @param integer $priority
  154.      *
  155.      * @return ProductVariation
  156.      */
  157.     public function setPriority($priority)
  158.     {
  159.         $this->priority $priority;
  160.         return $this;
  161.     }
  162.     /**
  163.      * Get priority
  164.      *
  165.      * @return int
  166.      */
  167.     public function getPriority()
  168.     {
  169.         return $this->priority;
  170.     }
  171.     /**
  172.      * @return ConfirmedProduct
  173.      */
  174.     public function getProduct()
  175.     {
  176.         return $this->product;
  177.     }
  178.     /**
  179.      * @param ConfirmedProduct $product
  180.      */
  181.     public function setProduct($product)
  182.     {
  183.         $this->product $product;
  184.     }
  185.     /**
  186.      * @return bool
  187.      */
  188.     public function isDisabled()
  189.     {
  190.         return $this->disabled;
  191.     }
  192.     /**
  193.      * @param bool $disabled
  194.      */
  195.     public function setDisabled($disabled)
  196.     {
  197.         $this->disabled $disabled;
  198.     }
  199.     /**
  200.      * @return Unit
  201.      */
  202.     public function getOrderUnit()
  203.     {
  204.         return $this->orderUnit;
  205.     }
  206.     /**
  207.      * @param Unit $orderUnit
  208.      */
  209.     public function setOrderUnit($orderUnit)
  210.     {
  211.         $this->orderUnit $orderUnit;
  212.     }
  213.     /**
  214.      * @return DateTime
  215.      */
  216.     public function getCreatedAt()
  217.     {
  218.         return $this->createdAt;
  219.     }
  220.     /**
  221.      * @return DateTime
  222.      */
  223.     public function getUpdatedAt()
  224.     {
  225.         return $this->updatedAt;
  226.     }
  227.     /**
  228.      * @return ProductVariation
  229.      * @ORM\PrePersist()
  230.      * @throws Exception
  231.      */
  232.     public function setCreatedAt()
  233.     {
  234.         $this->createdAt = new DateTime();
  235.         $this->updatedAt = new DateTime();
  236.         return $this;
  237.     }
  238.     /**
  239.      * Set updatedAt
  240.      *
  241.      * @return ProductVariation
  242.      * @ORM\PreUpdate
  243.      * @throws Exception
  244.      */
  245.     public function setUpdatedAt()
  246.     {
  247.         $this->updatedAt = new DateTime();
  248.         return $this;
  249.     }
  250. }