<?php
/*
* This file is part of the VPAutoBundle package.
*
* (c) CNSX <http://www.cnsx.net/>
*
*/
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*
* @ORM\Table(name="alert")
*
* @ORM\HasLifecycleCallbacks
*/
class Alert
{
/**
* @ORM\Id
*
* @ORM\Column(type="integer")
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $name;
/**
* User.
*
* @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="alerts")
*/
protected $user;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $room;
/**
* @ORM\Column(type="string", name="vehicle_group", nullable=true)
*/
protected $group;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $maker;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $class;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $category;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $color;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $model;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $energy;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $km_min;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $km_max;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $mileage_min;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $mileage_max;
/**
* @ORM\Column(name="created_at", type="datetime")
*/
protected $createdAt;
/**
* @ORM\Column(name="updated_at", type="datetime")
*/
protected $updatedAt;
/**
* @var text
*/
protected $type;
public function __construct()
{
$this->createdAt = new \DateTime('now');
$this->updatedAt = $this->createdAt;
$this->type = 'alert';
}
/**
* @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;
}
/**
* Get user.
*
* @return user
*/
public function getUser()
{
return $this->user;
}
/**
* Set user.
*
* @param user the value to set
*/
public function setUser($user): void
{
$this->user = $user;
}
/**
* Get room.
*
* @return room
*/
public function getRoom()
{
return $this->room;
}
/**
* Set room.
*
* @param room the value to set
*/
public function setRoom($room): void
{
$this->room = $room;
}
/**
* Get id.
*
* @return id
*/
public function getId()
{
return $this->id;
}
/**
* Set id.
*
* @param id the value to set
*/
public function setId($id): void
{
$this->id = $id;
}
/**
* Get name.
*
* @return name
*/
public function getName()
{
return $this->name;
}
/**
* Set name.
*
* @param name the value to set
*/
public function setName($name): void
{
$this->name = $name;
}
/**
* Get group.
*
* @return group
*/
public function getGroup()
{
return $this->group;
}
/**
* Set group.
*
* @param group the value to set
*/
public function setGroup($group): void
{
$this->group = $group;
}
/**
* Get maker.
*
* @return maker
*/
public function getMaker()
{
return $this->maker;
}
/**
* Set maker.
*
* @param maker the value to set
*/
public function setMaker($maker): void
{
$this->maker = $maker;
}
/**
* Get class.
*
* @return class
*/
public function getClass()
{
return $this->class;
}
/**
* Set class.
*
* @param string $class the value to set
*/
public function setClass($class): void
{
$this->class = $class;
}
/**
* Get category.
*
* @return category
*/
public function getCategory()
{
return $this->category;
}
/**
* Set category.
*
* @param category the value to set
*/
public function setCategory($category): void
{
$this->category = $category;
}
/**
* Get color.
*
* @return color
*/
public function getColor()
{
return $this->color;
}
/**
* Set color.
*
* @param string $color the value to set
*/
public function setColor($color): void
{
$this->color = $color;
}
/**
* Set type.
*
* @param string $type
*/
public function setType($type): void
{
$this->type = $type;
}
/**
* Get type.
*
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* Set model.
*
* @param string $model
*/
public function setModel($model): void
{
$this->model = $model;
}
/**
* Get model.
*
* @return string
*/
public function getModel()
{
return $this->model;
}
/**
* Set energy.
*
* @param string $energy
*/
public function setEnergy($energy): void
{
$this->energy = $energy;
}
/**
* Get energy.
*
* @return string
*/
public function getEnergy()
{
return $this->energy;
}
/**
* Set km_min.
*
* @param string $km_min
*/
public function setKmMin($km_min): void
{
$this->km_min = $km_min;
}
/**
* Get km_min.
*
* @return string
*/
public function getKmMin()
{
return $this->km_min;
}
/**
* Set km_max.
*
* @param string $km_max
*/
public function setKmMax($km_max): void
{
$this->km_max = $km_max;
}
/**
* Get km_max.
*
* @return string
*/
public function getKmMax()
{
return $this->km_max;
}
/**
* Set mileage_min.
*
* @param string $mileage_min
*/
public function setMileageMin($mileage_min): void
{
$this->mileage_min = $mileage_min;
}
/**
* Get mileage_min.
*
* @return string
*/
public function getMileageMin()
{
return $this->mileage_min;
}
/**
* Set mileage_max.
*
* @param string $mileage_max
*/
public function setMileageMax($mileage_max): void
{
$this->mileage_max = $mileage_max;
}
/**
* Get mileage_max.
*
* @return string
*/
public function getMileageMax()
{
return $this->mileage_max;
}
/**
* Get criteria.
*
* @return array
*/
public function getCriteria()
{
$criteria = [];
foreach (['name', 'room', 'group', 'model', 'maker', 'energy', 'color', 'category'] as $col) {
$criteria[$col] = $this->$col;
}
foreach (['km', 'mileage'] as $col) {
$criteria[$col] = [
'min' => $this->{$col.'_min'},
'max' => $this->{$col.'_max'},
];
}
return $criteria;
}
/**
* Set criteria.
*
* @param array the value to set
*/
public function setCriteria(array $criteria = []): void
{
foreach ($criteria as $col => $value) {
if (is_array($value)) {
if (isset($value['min'])) {
$this->{$col.'_min'} = $value['min'];
} else {
$this->{$col.'_min'} = null;
}
if (isset($value['max'])) {
$this->{$col.'_max'} = $value['max'];
} else {
$this->{$col.'_max'} = null;
}
} else {
$this->$col = $value;
}
}
}
}