src/Entity/PriceSpecialOffer.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Validator\Constraints as AppAssert;
  4. use App\Entity\Product\ConfirmedProduct;
  5. use DateTime;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. /**
  9.  * @ORM\Entity(repositoryClass="App\Repository\PriceSpecialOfferRepository")
  10.  * @ORM\Table(name="malys_price_special_offer")
  11.  * @ORM\HasLifecycleCallbacks()
  12.  * @package App\Entity
  13.  * @AppAssert\PriceSpecialOfferDates
  14.  * @AppAssert\PriceSpecialOfferType
  15.  */
  16. class PriceSpecialOffer
  17. {
  18.     /**
  19.      * @var integer
  20.      *
  21.      * @ORM\Column(name="id", type="integer")
  22.      * @ORM\Id
  23.      * @ORM\GeneratedValue(strategy="AUTO")
  24.      */
  25.     protected $id;
  26.     /**
  27.      * Many PriceOptimized have One Product
  28.      * @var ConfirmedProduct $product
  29.      * @ORM\ManyToOne(targetEntity="App\Entity\Product\ConfirmedProduct", inversedBy="specialOffers")
  30.      * @ORM\JoinColumn(name="product_id", referencedColumnName="id")
  31.      * @Assert\Type("App\Entity\Product\ConfirmedProduct")
  32.      */
  33.     protected $product;
  34.     /**
  35.      * @var DateTime
  36.      *
  37.      * @ORM\Column(name="start", type="datetime", nullable=false)
  38.      */
  39.     protected $start;
  40.     /**
  41.      * @var DateTime
  42.      *
  43.      * @ORM\Column(name="end", type="datetime", nullable=false)
  44.      */
  45.     protected $end;
  46.     /**
  47.      * @var float
  48.      *
  49.      * @ORM\Column(name="price", type="float", nullable=false)
  50.      * @Assert\NotBlank()
  51.      * @Assert\Type("float")
  52.      */
  53.     protected $price;
  54.     /**
  55.      * @var $type string
  56.      * @ORM\Column(name="type", type="string", nullable=false)
  57.      * @Assert\NotBlank()
  58.      */
  59.     protected $type;
  60.     /**
  61.      * @var string
  62.      *
  63.      * @ORM\Column(name="label", type="string", length=255, nullable=true)
  64.      * @Assert\Length(
  65.      *      max = 20,
  66.      *      maxMessage = "Max {{ limit }} caractères"
  67.      * )
  68.      */
  69.     protected $label;
  70.     /**
  71.      * @var boolean
  72.      *
  73.      * @ORM\Column(name="disable_on_end", type="boolean", options={"default" : false}, nullable=true)
  74.      */
  75.     protected $disableOnEnd;
  76.     /**
  77.      * @return int
  78.      */
  79.     public function getId()
  80.     {
  81.         return $this->id;
  82.     }
  83.     /**
  84.      * @param int $id
  85.      */
  86.     public function setId($id)
  87.     {
  88.         $this->id $id;
  89.     }
  90.     /**
  91.      * @return ConfirmedProduct
  92.      */
  93.     public function getProduct()
  94.     {
  95.         return $this->product;
  96.     }
  97.     /**
  98.      * @param ConfirmedProduct $product
  99.      */
  100.     public function setProduct(ConfirmedProduct $product)
  101.     {
  102.         $this->product $product;
  103.     }
  104.     /**
  105.      * @return DateTime
  106.      */
  107.     public function getStart()
  108.     {
  109.         return $this->start;
  110.     }
  111.     /**
  112.      * @param DateTime $start
  113.      */
  114.     public function setStart($start)
  115.     {
  116.         $this->start $start;
  117.     }
  118.     /**
  119.      * @return DateTime
  120.      */
  121.     public function getEnd()
  122.     {
  123.         return $this->end;
  124.     }
  125.     /**
  126.      * @param DateTime $end
  127.      */
  128.     public function setEnd($end)
  129.     {
  130.         $this->end $end;
  131.     }
  132.     /**
  133.      * @return float
  134.      */
  135.     public function getPrice()
  136.     {
  137.         return $this->price;
  138.     }
  139.     /**
  140.      * @param float $price
  141.      */
  142.     public function setPrice($price)
  143.     {
  144.         $this->price $price;
  145.     }
  146.     /**
  147.      * @return string
  148.      */
  149.     public function getType()
  150.     {
  151.         return $this->type;
  152.     }
  153.     /**
  154.      * @param string $type
  155.      */
  156.     public function setType($type)
  157.     {
  158.         $this->type $type;
  159.     }
  160.     public function getSupplier()
  161.     {
  162.         if ($this->getProduct() instanceof ConfirmedProduct) {
  163.             return $this->getProduct()->getSupplier();
  164.         }
  165.         return null;
  166.     }
  167.     /**
  168.      * @return string
  169.      */
  170.     public function getLabel()
  171.     {
  172.         return $this->label;
  173.     }
  174.     /**
  175.      * @param string $label
  176.      */
  177.     public function setLabel($label)
  178.     {
  179.         $this->label $label;
  180.     }
  181.     /**
  182.      * @return bool
  183.      */
  184.     public function isDisableOnEnd()
  185.     {
  186.         return $this->disableOnEnd;
  187.     }
  188.     /**
  189.      * @param bool $disableOnEnd
  190.      */
  191.     public function setDisableOnEnd($disableOnEnd)
  192.     {
  193.         $this->disableOnEnd $disableOnEnd;
  194.     }
  195. }