226 lines
4.4 KiB
PHP
226 lines
4.4 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
|
|
use DateTime;
|
|
|
|
/**
|
|
* @ORM\Entity
|
|
* @ORM\Table(name="subscription")
|
|
*/
|
|
class Subscription
|
|
{
|
|
/**
|
|
* @ORM\Id
|
|
* @ORM\Column(type="integer")
|
|
* @ORM\GeneratedValue(strategy="AUTO")
|
|
*/
|
|
protected $id;
|
|
|
|
// link to customer
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity="Customer")
|
|
* @ORM\JoinColumn(name="customer_id", referencedColumnName="id")
|
|
*/
|
|
protected $customer;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity="CustomerVehicle", inversedBy="subscriptions")
|
|
* @ORM\JoinColumn(name="customer_vehicle_id", referencedColumnName="id")
|
|
*/
|
|
protected $customer_vehicle;
|
|
|
|
// job orders associated with subscription
|
|
/**
|
|
* @ORM\OneToMany(targetEntity="JobOrder", mappedBy="subscription")
|
|
*/
|
|
protected $job_orders;
|
|
|
|
// email address
|
|
/**
|
|
* @ORM\Column(type="string", length=255, nullable=true)
|
|
*/
|
|
protected $email;
|
|
|
|
// date subscription was created
|
|
/**
|
|
* @ORM\Column(type="datetime")
|
|
*/
|
|
protected $date_create;
|
|
|
|
// date subscription starts
|
|
/**
|
|
* @ORM\Column(type="datetime", nullable=true)
|
|
*/
|
|
protected $date_start;
|
|
|
|
// date subscription ends
|
|
/**
|
|
* @ORM\Column(type="datetime", nullable=true)
|
|
*/
|
|
protected $date_end;
|
|
|
|
// date subscription was cancelled
|
|
/**
|
|
* @ORM\Column(type="datetime", nullable=true)
|
|
*/
|
|
protected $date_cancel;
|
|
|
|
// external api id (paymongo)
|
|
/**
|
|
* @ORM\Column(type="string", length=255, nullable=true)
|
|
*/
|
|
protected $ext_api_id;
|
|
|
|
// status of the subscription
|
|
/**
|
|
* @ORM\Column(type="string", length=50)
|
|
* @Assert\NotBlank()
|
|
*/
|
|
protected $status;
|
|
|
|
// other data related to the transaction
|
|
/**
|
|
* @ORM\Column(type="json")
|
|
*/
|
|
protected $metadata;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->date_create = new DateTime();
|
|
$this->date_start = null;
|
|
$this->date_end = null;
|
|
$this->date_cancel = null;
|
|
$this->job_orders = new ArrayCollection();
|
|
$this->metadata = [];
|
|
}
|
|
|
|
public function getID()
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function setCustomer(Customer $cust = null)
|
|
{
|
|
$this->customer = $cust;
|
|
return $this;
|
|
}
|
|
|
|
public function getCustomer()
|
|
{
|
|
return $this->customer;
|
|
}
|
|
|
|
public function setCustomerVehicle(CustomerVehicle $customer_vehicle)
|
|
{
|
|
$this->customer_vehicle = $customer_vehicle;
|
|
return $this;
|
|
}
|
|
|
|
public function getCustomerVehicle()
|
|
{
|
|
return $this->customer_vehicle;
|
|
}
|
|
|
|
public function setDateCreate(DateTime $date)
|
|
{
|
|
$this->date_create = $date;
|
|
return $this;
|
|
}
|
|
|
|
public function getDateCreate()
|
|
{
|
|
return $this->date_create;
|
|
}
|
|
|
|
public function setDateStart(DateTime $date)
|
|
{
|
|
$this->date_start = $date;
|
|
return $this;
|
|
}
|
|
|
|
public function getDateStart()
|
|
{
|
|
return $this->date_start;
|
|
}
|
|
|
|
public function setDateEnd(DateTime $date)
|
|
{
|
|
$this->date_end = $date;
|
|
return $this;
|
|
}
|
|
|
|
public function getDateEnd()
|
|
{
|
|
return $this->date_end;
|
|
}
|
|
|
|
public function setDateCancel(DateTime $date)
|
|
{
|
|
$this->date_cancel = $date;
|
|
return $this;
|
|
}
|
|
|
|
public function getDateCancel()
|
|
{
|
|
return $this->date_cancel;
|
|
}
|
|
|
|
public function setStatus($status)
|
|
{
|
|
$this->status = $status;
|
|
return $this;
|
|
}
|
|
|
|
public function getStatus()
|
|
{
|
|
return $this->status;
|
|
}
|
|
|
|
public function setEmail($email)
|
|
{
|
|
$this->email = $email;
|
|
return $this;
|
|
}
|
|
|
|
public function getEmail()
|
|
{
|
|
return $this->email;
|
|
}
|
|
|
|
public function setExtApiId($ext_api_id)
|
|
{
|
|
$this->ext_api_id = $ext_api_id;
|
|
return $this;
|
|
}
|
|
|
|
public function getExtApiId()
|
|
{
|
|
return $this->ext_api_id;
|
|
}
|
|
|
|
public function setMetadata($metadata)
|
|
{
|
|
$this->metadata = $metadata;
|
|
return $this;
|
|
}
|
|
|
|
public function getMetadata()
|
|
{
|
|
return $this->metadata;
|
|
}
|
|
|
|
public function getJobOrders()
|
|
{
|
|
return $this->job_orders;
|
|
}
|
|
|
|
public function getGatewayTransactions()
|
|
{
|
|
// TODO: get gateway transactions here via type and metadata
|
|
}
|
|
}
|