Add asserts/get/setters to battery entity

This commit is contained in:
Ramon Gutierrez 2018-01-12 03:12:35 +08:00
parent b4300d48de
commit 5c381c48e0

View file

@ -4,6 +4,7 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity
@ -23,6 +24,7 @@ class Battery
/**
* @ORM\ManyToOne(targetEntity="BatteryManufacturer", inversedBy="batteries")
* @ORM\JoinColumn(name="manufacturer_id", referencedColumnName="id")
* @Assert\NotBlank()
*/
protected $manufacturer;
@ -30,6 +32,7 @@ class Battery
/**
* @ORM\ManyToOne(targetEntity="BatteryModel", inversedBy="batteries")
* @ORM\JoinColumn(name="model_id", referencedColumnName="id")
* @Assert\NotBlank()
*/
protected $model;
@ -37,15 +40,16 @@ class Battery
/**
* @ORM\ManyToOne(targetEntity="BatterySize", inversedBy="batteries")
* @ORM\JoinColumn(name="size_id", referencedColumnName="id")
* @Assert\NotBlank()
*/
protected $size;
// vehicle
/**
* @ORM\ManyToOne(targetEntity="Vehicle", inversedBy="batteries")
* @ORM\JoinColumn(name="vehicle_id", referencedColumnName="id")
* @ORM\ManyToMany(targetEntity="Vehicle", inversedBy="batteries")
* @ORM\JoinTable(name="battery_vehicle")
*/
protected $vehicle;
protected $vehicles;
// customer vehicles
/**
@ -111,4 +115,174 @@ class Battery
{
$this->cust_vehicles = new ArrayCollection();
}
public function getID()
{
return $this->id;
}
public function setManufacturer($manufacturer)
{
$this->manufacturer = $manufacturer;
return $this;
}
public function getManufacturer()
{
return $this->manufacturer;
}
public function setModel($model)
{
$this->model = $model;
return $this;
}
public function getModel()
{
return $this->model;
}
public function setSize($size)
{
$this->size = $size;
return $this;
}
public function getSize()
{
return $this->size;
}
public function setVehicle($vehicle)
{
$this->vehicle = $vehicle;
return $this;
}
public function getVehicle()
{
return $this->vehicle;
}
public function setProductCode($prod_code)
{
$this->prod_code = $prod_code;
return $this;
}
public function getProductCode()
{
return $this->prod_code;
}
public function setWarrantyPersonal($warr_personal)
{
$this->warr_personal = $warr_personal;
return $this;
}
public function getWarrantyPersonal()
{
return $this->warr_personal;
}
public function setWarrantyCommercial($warr_commercial)
{
$this->warr_commercial = $warr_commercial;
return $this;
}
public function getWarrantyCommercial()
{
return $this->warr_commercial;
}
public function setReserveCapacity($res_capacity)
{
$this->res_capacity = $res_capacity;
return $this;
}
public function getReserveCapacity()
{
return $this->res_capacity;
}
public function setLength($length)
{
$this->length = $length;
return $this;
}
public function getLength()
{
return $this->length;
}
public function setWidth($width)
{
$this->width = $width;
return $this;
}
public function getWidth()
{
return $this->width;
}
public function setHeight($height)
{
$this->height = $height;
return $this;
}
public function getHeight()
{
return $this->height;
}
public function setTotalHeight($total_height)
{
$this->total_height = $total_height;
return $this;
}
public function getTotalHeight()
{
return $this->total_height;
}
public function setSellingPrice($sell_price)
{
$this->sell_price = $sell_price;
return $this;
}
public function getSellingPrice()
{
return $this->sell_price;
}
public function addCustomerVehicle(CustomerVehicle $cust_vehicle)
{
$this->cust_vehicles->add($cust_vehicle);
return $this;
}
public function clearCustomerVehicles()
{
$this->cust_vehicles->clear();
return $this;
}
public function getCustomerVehicles()
{
// has to return set of strings because symfony is trying to move away from role objects
$str_cust_vehicles = [];
foreach ($this->cust_vehicles as $cust_vehicle)
$str_cust_vehicles[] = $cust_vehicle->getName();
return $str_cust_vehicles;
}
}