<?php
namespace App\Entity;
use App\Service\Helper\DateTimeHelper;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use Exception;
/**
* @ORM\Table(name="leads__leads",
* indexes={
* @ORM\Index(columns={"phone"}),
* @ORM\Index(columns={"transmission_time"})
* })
* @ORM\Entity(repositoryClass="App\Repository\LeadRepository")
*/
class Lead
{
use IdTrait;
/**
* @ORM\Column(name="created_at", type="datetime")
*/
private DateTime $createdAt;
/**
* @ORM\Column(name="canceled_at", type="datetime", nullable=true)
*/
private ?DateTime $canceledAt = null;
/**
* @ORM\Column(name="transmission_time", type="datetime", nullable=true)
*/
private ?DateTime $transmissionTime = null;
/**
* @ORM\Column(name="phone", type="string", length=12)
*/
private string $phone;
/**
* @ORM\Column(name="car_brand", type="string", nullable=true)
*/
private ?string $carBrand = null;
/**
* @ORM\Column(name="car_model", type="string", nullable=true)
*/
private ?string $carModel = null;
/**
* @ORM\Column(name="car_vin", type="string", nullable=true)
*/
private ?string $carVin = null;
/**
* @ORM\Column(name="town_name", type="string", nullable=true)
*/
private ?string $townName = null;
/**
* @ORM\ManyToOne(targetEntity="Customer")
* @ORM\JoinColumn(name="customer_id", referencedColumnName="id", nullable=false)
**/
private Customer $customer;
/**
* @ORM\ManyToOne(targetEntity="User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false)
**/
private User $user;
/**
* @ORM\OneToOne(targetEntity="MangoCall")
* @ORM\JoinColumn(name="mango_call_id", referencedColumnName="id", nullable=true)
**/
private ?MangoCall $mangoCall;
/**
* @ORM\OneToOne(targetEntity="Order")
* @ORM\JoinColumn(name="order_id", referencedColumnName="id", nullable=true)
**/
private ?Order $order;
/**
* @ORM\Column(name="comment", type="text", nullable=true)
*/
private ?string $comment;
/**
* @ORM\Column(name="confirmed", type="boolean", options={"default":1})
*/
private bool $confirmed = true;
/**
* @ORM\Column(name="deprecated_order_id", type="integer", nullable=true, unique=true)
*/
private ?int $deprecatedOrderId = null;
/**
* @throws Exception
*/
public function __construct(
string $phone,
Customer $customer,
User $user,
?MangoCall $mangoCall
)
{
$this->phone = $phone;
$this->customer = $customer;
$this->user = $user;
$this->mangoCall = $mangoCall;
$this->createdAt = DateTimeHelper::getNowDateTime();
}
public function getUser(): User
{
return $this->user;
}
public function getCreatedAt(): DateTime
{
return $this->createdAt;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function getCustomerFirstName(): string
{
return $this->customer->getFirstName();
}
public function getCustomerFatherName(): string
{
return $this->customer->getFatherName();
}
public function getCustomerSureName(): string
{
return $this->customer->getSureName();
}
public function getCustomer(): Customer
{
return $this->customer;
}
public function getComment(): ?string
{
return $this->comment;
}
public function setComment(?string $comment): Lead
{
$this->comment = $comment;
return $this;
}
public function getCarBrand(): ?string
{
return $this->carBrand;
}
public function setCarBrand(?string $carBrand): Lead
{
$this->carBrand = $carBrand;
return $this;
}
public function getCarModel(): ?string
{
return $this->carModel;
}
public function setCarModel(?string $carModel): Lead
{
$this->carModel = $carModel;
return $this;
}
public function getCarVin(): ?string
{
return $this->carVin;
}
public function setCarVin(?string $carVin): Lead
{
$this->carVin = $carVin;
return $this;
}
public function setConfirmed(bool $confirmed): Lead
{
$this->confirmed = $confirmed;
return $this;
}
public function getTownName(): ?string
{
return $this->townName;
}
public function setTownName(?string $townName): Lead
{
$this->townName = $townName;
return $this;
}
public function getDeprecatedOrderId(): ?int
{
return $this->deprecatedOrderId;
}
public function setDeprecatedOrderId(?int $deprecatedOrderId): Lead
{
$this->deprecatedOrderId = $deprecatedOrderId;
return $this;
}
public function getOrder(): ?Order
{
return $this->order;
}
public function getOrderId(): ?int
{
return $this->order?->getId();
}
public function setOrder(?Order $order): Lead
{
$this->order = $order;
return $this;
}
}