<?php
/*
* This file is part of the VPAutoBundle package.
*
* (c) KnpLabs <http://www.knplabs.com/>
*
*/
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\VehicleAlertRepository")
*
* @ORM\Table(name="vehicle_alert")
*
* @ORM\HasLifecycleCallbacks
*/
class VehicleAlert
{
/**
* @ORM\Id
*
* @ORM\ManyToOne(targetEntity="User", inversedBy="vehicleAlerts", cascade={"persist"})
*/
protected $user;
/**
* @ORM\Column(type="integer")
*/
private $lastPrice;
/**
* @ORM\Column(name="created_at", type="datetime")
*/
private $createdAt;
/**
* @ORM\Column(name="updated_at", type="datetime")
*/
private $updatedAt;
public function __construct(/**
* @ORM\Id
*
* @ORM\ManyToOne(targetEntity="App\Entity\Vehicle", inversedBy="usersToAlert")
*
* @ORM\JoinColumn(name="vehicle_id", onDelete="CASCADE")
*/
private Vehicle $vehicle)
{
$this->createdAt = new \DateTime('now');
$this->updatedAt = $this->createdAt;
$this->lastPrice = 0;
}
/**
* @ORM\PreUpdate
*/
public function updatedAtChange(): void
{
$this->updatedAt = new \DateTime('now');
}
/**
* Set createdAt.
*
* @param \DateTime $createdAt
*/
public function setCreatedAt($createdAt): void
{
$this->createdAt = $createdAt;
}
/**
* Get createdAt.
*
* @return \DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Set updatedAt.
*
* @param \DateTime $updatedAt
*/
public function setUpdatedAt($updatedAt): void
{
$this->updatedAt = $updatedAt;
}
/**
* Get updatedAt.
*
* @return \DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* Set lastPrice.
*
* @param int $lastPrice
*/
public function setLastPrice($lastPrice): void
{
$this->lastPrice = $lastPrice;
}
/**
* Get lastPrice.
*
* @return int
*/
public function getLastPrice()
{
return $this->lastPrice;
}
/**
* Set user.
*/
public function setUser(User $user): void
{
$this->user = $user;
}
/**
* Get user.
*
* @return User
*/
public function getUser()
{
return $this->user;
}
/**
* Set vehicle.
*/
public function setVehicle(Vehicle $vehicle): void
{
$this->vehicle = $vehicle;
}
/**
* Get vehicle.
*
* @return Vehicle
*/
public function getVehicle()
{
return $this->vehicle;
}
}