src/AtechNet/CoreBundle/Entity/ProductPriceLog.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\AtechNet\CoreBundle\Entity;
  3. use Doctrine\ORM\Mapping\Column;
  4. use Doctrine\ORM\Mapping\Entity;
  5. use Doctrine\ORM\Mapping\GeneratedValue;
  6. use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
  7. use Doctrine\ORM\Mapping\Id;
  8. use Doctrine\ORM\Mapping\JoinColumn;
  9. use Doctrine\ORM\Mapping\ManyToOne;
  10. use Doctrine\ORM\Mapping\PrePersist;
  11. use Doctrine\ORM\Mapping\Table as Table;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. /**
  14.  * ProductPriceLog
  15.  *
  16.  * @Table(name="product_price_log")
  17.  * @Entity
  18.  * @HasLifecycleCallbacks
  19.  */
  20. class ProductPriceLog
  21. {
  22.     /**
  23.      * @Id
  24.      * @Column(name="id", type="integer")
  25.      * @GeneratedValue(strategy="AUTO")
  26.      */
  27.     private $id;
  28.     /**
  29.      * @var Domain
  30.      *
  31.      * @Assert\NotNull
  32.      *
  33.      * @ManyToOne(targetEntity="Domain")
  34.      * @JoinColumn(name="domain_id", referencedColumnName="id")
  35.      */
  36.     private $domain;
  37.     /**
  38.      * @var Product
  39.      *
  40.      * @Assert\NotNull
  41.      *
  42.      * @ManyToOne(targetEntity="Product", inversedBy="priceLogEntries")
  43.      * @JoinColumn(name="product_id", referencedColumnName="id")
  44.      */
  45.     private $product;
  46.     /**
  47.      * @var User
  48.      *
  49.      * @ManyToOne(targetEntity="User")
  50.      * @JoinColumn(name="created_by", referencedColumnName="id")
  51.      */
  52.     private $createdBy;
  53.     /**
  54.      * @var float
  55.      *
  56.      * @Column(name="price_old", type="float", nullable=true)
  57.      */
  58.     private $oldPrice = null;
  59.     /**
  60.      * @var float
  61.      *
  62.      * @Column(name="price_new", type="float", nullable=true)
  63.      */
  64.     private $newPrice = null;
  65.     /**
  66.      * @var \DateTime
  67.      *
  68.      * @Column(name="created", type="datetime", nullable=false)
  69.      */
  70.     private $created;
  71.     public function __construct()
  72.     {
  73.         $this->created = new \DateTime();
  74.     }
  75.     /**
  76.      * @return int
  77.      */
  78.     public function getId(): int
  79.     {
  80.         return $this->id;
  81.     }
  82.     /**
  83.      * @param int $id
  84.      */
  85.     public function setId(int $id): void
  86.     {
  87.         $this->id = $id;
  88.     }
  89.     /**
  90.      * @return Domain
  91.      */
  92.     public function getDomain(): Domain
  93.     {
  94.         return $this->domain;
  95.     }
  96.     /**
  97.      * @param Domain $domain
  98.      */
  99.     public function setDomain(Domain $domain): void
  100.     {
  101.         $this->domain = $domain;
  102.     }
  103.     /**
  104.      * @return Product
  105.      */
  106.     public function getProduct(): Product
  107.     {
  108.         return $this->product;
  109.     }
  110.     /**
  111.      * @param Product $product
  112.      */
  113.     public function setProduct(Product $product): void
  114.     {
  115.         $this->product = $product;
  116.     }
  117.     /**
  118.      * @return User
  119.      */
  120.     public function getCreatedBy(): User
  121.     {
  122.         return $this->createdBy;
  123.     }
  124.     /**
  125.      * @param User $createdBy
  126.      */
  127.     public function setCreatedBy(User $createdBy): void
  128.     {
  129.         $this->createdBy = $createdBy;
  130.     }
  131.     /**
  132.      * @return float|null
  133.      */
  134.     public function getOldPrice(): ?float
  135.     {
  136.         return $this->oldPrice;
  137.     }
  138.     /**
  139.      * @param float|null $oldPrice
  140.      */
  141.     public function setOldPrice(?float $oldPrice): void
  142.     {
  143.         $this->oldPrice = $oldPrice;
  144.     }
  145.     /**
  146.      * @return float|null
  147.      */
  148.     public function getNewPrice(): ?float
  149.     {
  150.         return $this->newPrice;
  151.     }
  152.     /**
  153.      * @param float|null $newPrice
  154.      */
  155.     public function setNewPrice(?float $newPrice): void
  156.     {
  157.         $this->newPrice = $newPrice;
  158.     }
  159.     /**
  160.      * @return \DateTime
  161.      */
  162.     public function getCreated(): \DateTime
  163.     {
  164.         return $this->created;
  165.     }
  166.     /**
  167.      * @param \DateTime $created
  168.      */
  169.     public function setCreated(\DateTime $created): void
  170.     {
  171.         $this->created = $created;
  172.     }
  173.     /**
  174.      * @PrePersist
  175.      */
  176.     public function setTimestamps()
  177.     {
  178.         if ($this->created === null) {
  179.             $this->created = new \DateTime();
  180.         }
  181.     }
  182. }