<?php
namespace App\AtechNet\CoreBundle\Entity;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\JoinColumn;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\PrePersist;
use Doctrine\ORM\Mapping\Table as Table;
use Symfony\Component\Validator\Constraints as Assert;
/**
* ProductPriceLog
*
* @Table(name="product_price_log")
* @Entity
* @HasLifecycleCallbacks
*/
class ProductPriceLog
{
/**
* @Id
* @Column(name="id", type="integer")
* @GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var Domain
*
* @Assert\NotNull
*
* @ManyToOne(targetEntity="Domain")
* @JoinColumn(name="domain_id", referencedColumnName="id")
*/
private $domain;
/**
* @var Product
*
* @Assert\NotNull
*
* @ManyToOne(targetEntity="Product", inversedBy="priceLogEntries")
* @JoinColumn(name="product_id", referencedColumnName="id")
*/
private $product;
/**
* @var User
*
* @ManyToOne(targetEntity="User")
* @JoinColumn(name="created_by", referencedColumnName="id")
*/
private $createdBy;
/**
* @var float
*
* @Column(name="price_old", type="float", nullable=true)
*/
private $oldPrice = null;
/**
* @var float
*
* @Column(name="price_new", type="float", nullable=true)
*/
private $newPrice = null;
/**
* @var \DateTime
*
* @Column(name="created", type="datetime", nullable=false)
*/
private $created;
public function __construct()
{
$this->created = new \DateTime();
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @param int $id
*/
public function setId(int $id): void
{
$this->id = $id;
}
/**
* @return Domain
*/
public function getDomain(): Domain
{
return $this->domain;
}
/**
* @param Domain $domain
*/
public function setDomain(Domain $domain): void
{
$this->domain = $domain;
}
/**
* @return Product
*/
public function getProduct(): Product
{
return $this->product;
}
/**
* @param Product $product
*/
public function setProduct(Product $product): void
{
$this->product = $product;
}
/**
* @return User
*/
public function getCreatedBy(): User
{
return $this->createdBy;
}
/**
* @param User $createdBy
*/
public function setCreatedBy(User $createdBy): void
{
$this->createdBy = $createdBy;
}
/**
* @return float|null
*/
public function getOldPrice(): ?float
{
return $this->oldPrice;
}
/**
* @param float|null $oldPrice
*/
public function setOldPrice(?float $oldPrice): void
{
$this->oldPrice = $oldPrice;
}
/**
* @return float|null
*/
public function getNewPrice(): ?float
{
return $this->newPrice;
}
/**
* @param float|null $newPrice
*/
public function setNewPrice(?float $newPrice): void
{
$this->newPrice = $newPrice;
}
/**
* @return \DateTime
*/
public function getCreated(): \DateTime
{
return $this->created;
}
/**
* @param \DateTime $created
*/
public function setCreated(\DateTime $created): void
{
$this->created = $created;
}
/**
* @PrePersist
*/
public function setTimestamps()
{
if ($this->created === null) {
$this->created = new \DateTime();
}
}
}