<?php
namespace App\Entity\Quote;
use App\Entity\AppUser;
use App\Repository\Quote\QuoteRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=QuoteRepository::class)
*/
class Quote
{
const STATUS_CREATED = 'created';
const STATUS_APPROVED = 'approved';
const STATUS_ACCEPTED = 'accepted';
const STATUS_CANCELLED = 'cancelled';
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="datetime_immutable")
*/
private $createdAt;
/**
* @ORM\ManyToOne(targetEntity=AppUser::class, inversedBy="quotes")
* @ORM\JoinColumn(nullable=false)
*/
private $createdBy;
/**
* @ORM\OneToMany(targetEntity=QuoteService::class, mappedBy="quote")
*/
private $services;
/**
* @ORM\ManyToOne(targetEntity=Client::class, inversedBy="quotes")
* @ORM\JoinColumn(nullable=false)
*/
private $client;
/**
* @ORM\Column(type="string", length=255)
*/
private $status;
/**
* @ORM\Column(type="text")
*/
private $content;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $emailContent;
/**
* @ORM\OneToMany(targetEntity=Log::class, mappedBy="quote")
*/
private $logs;
public function __construct()
{
$this->services = new ArrayCollection();
$this->logs = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getCreatedBy(): ?AppUser
{
return $this->createdBy;
}
public function setCreatedBy(?AppUser $createdBy): self
{
$this->createdBy = $createdBy;
return $this;
}
/**
* @return Collection<int, QuoteService>
*/
public function getServices(): Collection
{
return $this->services;
}
public function addService(QuoteService $service): self
{
if (!$this->services->contains($service)) {
$this->services[] = $service;
$service->setQuote($this);
}
return $this;
}
public function removeService(QuoteService $service): self
{
if ($this->services->removeElement($service)) {
// set the owning side to null (unless already changed)
if ($service->getQuote() === $this) {
$service->setQuote(null);
}
}
return $this;
}
public function getClient(): ?Client
{
return $this->client;
}
public function setClient(?Client $client): self
{
$this->client = $client;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(string $status): self
{
$this->status = $status;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(string $content): self
{
$this->content = $content;
return $this;
}
public function getEmailContent(): ?string
{
return $this->emailContent;
}
public function setEmailContent(?string $emailContent): self
{
$this->emailContent = $emailContent;
return $this;
}
/**
* @return Collection<int, Log>
*/
public function getLogs(): Collection
{
return $this->logs;
}
public function addLog(Log $log): self
{
if (!$this->logs->contains($log)) {
$this->logs[] = $log;
$log->setQuote($this);
}
return $this;
}
public function removeLog(Log $log): self
{
if ($this->logs->removeElement($log)) {
// set the owning side to null (unless already changed)
if ($log->getQuote() === $this) {
$log->setQuote(null);
}
}
return $this;
}
}