Add initial entities for battery, customer and vehicle

This commit is contained in:
Kendrick Chan 2018-01-08 23:59:13 +08:00
parent 9859242400
commit 43886c729d
11 changed files with 589 additions and 2 deletions

114
src/Entity/Battery.php Normal file
View file

@ -0,0 +1,114 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity
* @ORM\Table(name="battery")
*/
class Battery
{
// unique id
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
// manufacturer
/**
* @ORM\ManyToOne(targetEntity="BatteryManufacturer", inversedBy="batteries")
* @ORM\JoinColumn(name="manufacturer_id", referencedColumnName="id")
*/
protected $manufacturer;
// model
/**
* @ORM\ManyToOne(targetEntity="BatteryModel", inversedBy="batteries")
* @ORM\JoinColumn(name="model_id", referencedColumnName="id")
*/
protected $model;
// size
/**
* @ORM\ManyToOne(targetEntity="BatterySize", inversedBy="batteries")
* @ORM\JoinColumn(name="size_id", referencedColumnName="id")
*/
protected $size;
// vehicle
/**
* @ORM\ManyToOne(targetEntity="Vehicle", inversedBy="batteries")
* @ORM\JoinColumn(name="vehicle_id", referencedColumnName="id")
*/
protected $vehicle;
// customer vehicles
/**
* @ORM\OneToMany(targetEntity="CustomerVehicle", mappedBy="curr_battery")
*/
protected $cust_vehicles;
// product code
/**
* @ORM\Column(type="string", length=80)
*/
protected $prod_code;
// warranty personal
/**
* @ORM\Column(type="smallint")
*/
protected $warr_personal;
// warranty commercial
/**
* @ORM\Column(type="smallint")
*/
protected $warr_commercial;
// reserve capacity
/**
* @ORM\Column(type="smallint")
*/
protected $res_capacity;
// length
/**
* @ORM\Column(type="smallint")
*/
protected $length;
// width
/**
* @ORM\Column(type="smallint")
*/
protected $width;
// height
/**
* @ORM\Column(type="smallint")
*/
protected $height;
// total height
/**
* @ORM\Column(type="smallint")
*/
protected $total_height;
// selling price
/**
* @ORM\Column(type="decimal", precision=7, scale=2)
*/
protected $sell_price;
public function __construct()
{
$this->cust_vehicles = new ArrayCollection();
}
}

View file

@ -0,0 +1,38 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity
* @ORM\Table(name="battery_manufacturer")
*/
class BatteryManufacturer
{
// unique id
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
// name
/**
* @ORM\Column(type="string", length=80)
*/
protected $name;
// battery
/**
* @ORM\OneToMany(targetEntity="Battery", mappedBy="manufacturer")
*/
protected $batteries;
public function __construct()
{
$this->batteries = new ArrayCollection();
}
}

View file

@ -0,0 +1,37 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="battery_model")
*/
class BatteryModel
{
// unique id
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
// name
/**
* @ORM\Column(type="string", length=80)
*/
protected $name;
// battery
/**
* @ORM\OneToMany(targetEntity="Battery", mappedBy="manufacturer")
*/
protected $batteries;
public function __construct()
{
$this->batteries = new ArrayCollection();
}
}

View file

@ -0,0 +1,38 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity
* @ORM\Table(name="battery_size")
*/
class BatterySize
{
// unique id
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
// name
/**
* @ORM\Column(type="string", length=80)
*/
protected $name;
// battery
/**
* @ORM\OneToMany(targetEntity="Battery", mappedBy="manufacturer")
*/
protected $batteries;
public function __construct()
{
$this->batteries = new ArrayCollection();
}
}

64
src/Entity/Customer.php Normal file
View file

@ -0,0 +1,64 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity
* @ORM\Table(name="customer")
*/
class Customer
{
// unique id
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
// first name
/**
* @ORM\Column(type="string", length=80)
*/
protected $first_name;
// last name
/**
* @ORM\Column(type="string", length=80)
*/
protected $last_name;
// mobile numbers linked to this customer
/**
* @ORM\OneToMany(targetEntity="MobileNumber", mappedBy="customer")
*/
protected $numbers;
// mobile sessions linked to this customer
/**
* @ORM\OneToMany(targetEntity="MobileSession", mappedBy="customer")
*/
protected $sessions;
// vehicles linked to customer
/**
* @ORM\OneToMany(targetEntity="CustomerVehicle", mappedBy="customer")
*/
protected $vehicles;
// if any of their mobile numbers have been confirmed
/**
* @ORM\Column(type="boolean")
*/
protected $flag_confirmed;
public function __construct()
{
$this->numbers = new ArrayCollection();
$this->sessions = new ArrayCollection();
$this->vehicles = new ArrayCollection();
}
}

View file

@ -0,0 +1,96 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="customer_vehicle")
*/
class CustomerVehicle
{
// unique id
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
// user-defined name for vehicle
/**
* @ORM\Column(type="string", length=80)
*/
protected $name;
// link to customer
/**
* @ORM\ManyToOne(targetEntity="Customer", inversedBy="vehicles")
* @ORM\JoinColumn(name="customer_id", referencedColumnName="id")
*/
protected $customer;
// vehicle
/**
* @ORM\ManyToOne(targetEntity="Vehicle", inversedBy="customers")
* @ORM\JoinColumn(name="vehicle_id", referencedColumnName="id")
*/
protected $vehicle;
// plate number
/**
* @ORM\Column(type="string", length=10)
*/
protected $plate_number;
// model year
/**
* @ORM\Column(type="smallint")
*/
protected $model_year;
// vehicle status (new / second-hand)
/**
* @ORM\Column(type="string", length=15)
*/
protected $status_condition;
// fuel type - diesel, gas
/**
* @ORM\Column(type="string", length=15)
*/
protected $fuel_type;
// warranty code
// TODO: figure out how to check expiration
/**
* @ORM\Column(type="string", length=20)
*/
protected $warranty_code;
// date that battery warranty expires
/**
* @ORM\Column(type="date")
*/
protected $warranty_expiration;
// link to current battery
/**
* @ORM\ManyToOne(targetEntity="Battery", inversedBy="cust_vehicles")
* @ORM\JoinColumn(name="battery_id", referencedColumnName="id")
*/
protected $curr_battery;
// vehicle using motolite battery?
/**
* @ORM\Column(type="boolean")
*/
protected $flag_motolite_battery;
// is vehicle still active?
/**
* @ORM\Column(type="boolean")
*/
protected $flag_active;
}

View file

@ -0,0 +1,58 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="mobile_number")
*/
class MobileNumber
{
// the actual mobile number
// format is "639171112233", no prefix 0, no prefix +
/**
* @ORM\Id
* @ORM\Column(type="string", length=12)
*/
protected $id;
// customer it belongs to
/**
* @ORM\ManyToOne(targetEntity="Customer", inversedBy="numbers")
* @ORM\JoinColumn(name="customer_id", referencedColumnName="id")
*/
protected $customer;
// confirm code sent via sms
// should be unique
/**
* @ORM\Column(type="string", length=10, nullable=true, unique=true)
*/
protected $confirm_code;
// date entered into system
/**
* @ORM\Column(type="datetime", nullable=true)
*/
protected $date_registered;
// date confirmed
/**
* @ORM\Column(type="datetime", nullable=true)
*/
protected $date_confirmed;
// is this customer confirmed via sms code already?
/**
* @ORM\Column(type="boolean")
*/
protected $flag_confirmed;
public function __construct()
{
$this->confirm_code = null;
$this->flag_confirmed = false;
}
}

View file

@ -0,0 +1,42 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use DateTime;
/**
* @ORM\Entity
* @ORM\Table(name="mobile_session")
*/
class MobileSession
{
// unique id
/**
* @ORM\Id
* @ORM\Column(type="string", length=10)
*/
protected $id;
// link to customer
/**
* @ORM\ManyToOne(targetEntity="Customer", inversedBy="sessions")
* @ORM\JoinColumn(name="customer_id", referencedColumnName="id")
*/
protected $customer;
// date the session id was generated and sent to mobile app
/**
* @ORM\Column(type="datetime")
*/
protected $date_generated;
// TODO: get the details we can recover from the phone
public function __construct()
{
// default date generated to now
$this->date_generated = new DateTime();
}
}

View file

@ -61,8 +61,6 @@ class User implements AdvancedUserInterface, Serializable
*/
protected $email;
public function __construct()
{
$this->roles = new ArrayCollection();

64
src/Entity/Vehicle.php Normal file
View file

@ -0,0 +1,64 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity
* @ORM\Table(name="vehicle")
*/
class Vehicle
{
// unique id
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
// customer vehicles
/**
* @ORM\OneToMany(targetEntity="CustomerVehicle", mappedBy="customer")
*/
protected $customers;
// manufacturer
/**
* @ORM\ManyToOne(targetEntity="VehicleManufacturer", inversedBy="vehicles")
* @ORM\JoinColumn(name="manufacturer_id", referencedColumnName="id")
*/
protected $manufacturer;
// make
/**
* @ORM\Column(type="string", length=80)
*/
protected $make;
// model year from
/**
* @ORM\Column(type="smallint")
*/
protected $model_year_from;
// model year to
/**
* @ORM\Column(type="smallint")
*/
protected $model_year_to;
// link to batteries compatible with this vehicle
/**
* @ORM\OneToMany(targetEntity="Battery", mappedBy="vehicle")
*/
protected $batteries;
public function __construct()
{
$this->customers = new ArrayCollection();
$this->batteries = new ArrayCollection();
}
}

View file

@ -0,0 +1,38 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity
* @ORM\Table(name="vehicle_manufacturer")
*/
class VehicleManufacturer
{
// unique id
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
// name
/**
* @ORM\Column(type="string", length=80)
*/
protected $name;
// vehicles
/**
* @ORM\OneToMany(targetEntity="Vehicle", mappedBy="manufacturer")
*/
protected $vehicles;
public function __construct()
{
$this->vehicles = new ArrayCollection();
}
}