Add ticket entity and associations

This commit is contained in:
Ramon Gutierrez 2018-01-31 03:03:28 +08:00
parent bc80f7100f
commit 9d74fd9a1d
3 changed files with 233 additions and 0 deletions

View file

@ -63,6 +63,12 @@ class Customer
*/
protected $job_orders;
// tickets made by customer
/**
* @ORM\OneToMany(targetEntity="Ticket", mappedBy="customer")
*/
protected $tickets;
// if any of their mobile numbers have been confirmed
/**
* @ORM\Column(type="boolean")
@ -185,4 +191,14 @@ class Customer
{
return $this->flag_confirmed;
}
public function getJobOrders()
{
return $this->job_orders;
}
public function getTickets()
{
return $this->tickets;
}
}

205
src/Entity/Ticket.php Normal file
View file

@ -0,0 +1,205 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity
* @ORM\Table(name="ticket")
*/
class Ticket
{
// unique id
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
// date ticket was created
/**
* @ORM\Column(type="datetime")
*/
protected $date_create;
// status of the ticket
/**
* @ORM\Column(type="string", length=15)
*/
protected $status;
// ticket type
/**
* @ORM\Column(type="string", length=15)
*/
protected $type;
// user defined ticket type
/**
* @ORM\Column(type="string", length=80, nullable=true)
*/
protected $other_type;
// first name of ticket owner
/**
* @ORM\Column(type="string", length=80, nullable=true)
*/
protected $first_name;
// last name of ticket owner
/**
* @ORM\Column(type="string", length=80, nullable=true)
*/
protected $last_name;
// contact number of ticket owner
/**
* @ORM\Column(type="string", length=20, nullable=true)
*/
protected $contact_num;
// details of this ticket
/**
* @ORM\Column(type="text", nullable=true)
*/
protected $details;
// user that created the ticket
/**
* @ORM\ManyToOne(targetEntity="User", inversedBy="tickets")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
protected $created_by;
// customer associated with the ticket (optional)
/**
* @ORM\ManyToOne(targetEntity="Customer", inversedBy="tickets")
* @ORM\JoinColumn(name="customer_id", referencedColumnName="id", nullable=true)
* Assert\NotBlank()
*/
protected $customer;
public function __construct()
{
$this->date_create = new DateTime();
}
public function getID()
{
return $this->id;
}
public function setDateCreate($date_create)
{
$this->date_create = $date_create;
return $this;
}
public function getDateCreate()
{
return $this->date_create;
}
public function setStatus($status)
{
$this->status = $status;
return $this;
}
public function getStatus()
{
return $this->status;
}
public function setType($type)
{
$this->type = $type;
return $this;
}
public function getType()
{
return $this->type;
}
public function setOtherType($other_type)
{
$this->other_type = $other_type;
return $this;
}
public function getOtherType()
{
return $this->other_type;
}
public function setFirstName($first_name)
{
$this->first_name = $first_name;
return $this;
}
public function getFirstName()
{
return $this->first_name;
}
public function setLastName($last_name)
{
$this->last_name = $last_name;
return $this;
}
public function getLastName()
{
return $this->last_name;
}
public function setContactNumber($num)
{
$this->contact_num = $num;
return $this;
}
public function getContactNumber()
{
return $this->contact_num;
}
public function setDetails($details)
{
$this->details = $details;
return $this;
}
public function getDetails()
{
return $this->details;
}
public function setCreatedBy(User $created_by)
{
$this->created_by = $created_by;
return $this;
}
public function getCreatedBy()
{
return $this->created_by;
}
public function setCustomer(Customer $customer)
{
$this->customer = $customer;
return $this;
}
public function getCustomer()
{
return $this->customer;
}
}

View file

@ -79,11 +79,18 @@ class User implements AdvancedUserInterface, Serializable
*/
protected $job_orders_assigned;
// tickets made by this user
/**
* @ORM\OneToMany(targetEntity="Ticket", mappedBy="created_by")
*/
protected $tickets;
public function __construct()
{
$this->roles = new ArrayCollection();
$this->job_orders_created = new ArrayCollection();
$this->job_orders_assigned = new ArrayCollection();
$this->tickets = new ArrayCollection();
$this->enabled = true;
}
@ -267,4 +274,9 @@ class User implements AdvancedUserInterface, Serializable
{
return $this->job_orders_assigned;
}
public function getTickets()
{
return $this->tickets;
}
}