<?php
namespace App\Entity;
use App\Repository\ComplaintLetterRepository;
use DateTime;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: ComplaintLetterRepository::class)]
#[ORM\Table(name: 'complaint_letter')]
class ComplaintLetter
{
#[ORM\Id]
#[ORM\GeneratedValue(strategy: "AUTO")]
#[ORM\Column(type: "integer")]
private ?int $id;
#[ORM\Column(type: 'datetime')]
private ?DateTime $createdAt;
#[ORM\Column(type: "boolean")]
private bool $isDeleted = false;
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'complaintLetters')]
#[ORM\JoinColumn(nullable: false)]
private User $user;
/**
* @var Collection<Charge>|array<Charge>
*/
#[ORM\OneToMany(mappedBy: 'complaintLetter', targetEntity: Charge::class)]
private Collection|array $charges;
/**
* @var Collection<InsuranceDisasterDeclaration>|array<Charge>
*/
#[ORM\OneToMany(mappedBy: 'complaintLetter', targetEntity: InsuranceDisasterDeclaration::class)]
private Collection|array $insuranceDisasterDeclarations;
#[Assert\Choice(callback: 'getCivilities', multiple: false)]
#[ORM\Column(type: 'string', length: 255)]
private ?string $civility;
#[ORM\Column(type: 'boolean')]
private bool $isInsured;
#[ORM\Column(type: 'datetime')]
private DateTime $date;
#[ORM\Column(type: 'string', length: 255)]
private string $address;
#[ORM\Column(type: 'string', length: 255)]
private string $type;
#[ORM\Column(type: 'text')]
private string $circumstance;
#[ORM\ManyToOne(targetEntity: Insurance::class, inversedBy: 'complaintLetters')]
#[ORM\JoinColumn(nullable: true)]
private ?Insurance $insurance;
/**
* @var Collection<Item>|array<Item>
*/
#[ORM\ManyToMany(targetEntity: Item::class, inversedBy: 'complaintLetters')]
private Collection|array $items;
#[ORM\Column(type: 'text')]
private string $degradation;
#[ORM\Column(type: 'text')]
private string $evaluation;
public function __construct()
{
$this->createdAt = new DateTime();
$this->items = new \Doctrine\Common\Collections\ArrayCollection();
}
public function __toString()
{
return "#" . $this->id . " - " . $this->createdAt->format("d/m/Y H:i");
}
public static function getCivilities(): array
{
$arr = [
"Mr",
"Mme"
];
return array_combine($arr, $arr);
}
public function getId(): ?int
{
return $this->id;
}
/**
* Set civility
*
* @param string $civility
*
* @return ComplaintLetter
*/
public function setCivility($civility)
{
$this->civility = $civility;
return $this;
}
/**
* Get civility
*
* @return string
*/
public function getCivility()
{
return $this->civility;
}
/**
* Set isInsured
*
* @param boolean $isInsured
*
* @return ComplaintLetter
*/
public function setIsInsured($isInsured)
{
$this->isInsured = $isInsured;
return $this;
}
/**
* Get isInsured
*
* @return bool
*/
public function getIsInsured()
{
return $this->isInsured;
}
/**
* Set date
*
* @param DateTime $date
*
* @return ComplaintLetter
*/
public function setDate($date)
{
$this->date = $date;
return $this;
}
/**
* Get date
*
* @return DateTime
*/
public function getDate()
{
return $this->date;
}
/**
* Set address
*
* @param string $address
*
* @return ComplaintLetter
*/
public function setAddress($address)
{
$this->address = $address;
return $this;
}
/**
* Get address
*
* @return string
*/
public function getAddress()
{
return $this->address;
}
/**
* Set type
*
* @param string $type
*
* @return ComplaintLetter
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* Get type
*
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* Set circumstance
*
* @param string $circumstance
*
* @return ComplaintLetter
*/
public function setCircumstance($circumstance)
{
$this->circumstance = $circumstance;
return $this;
}
/**
* Get circumstance
*
* @return string
*/
public function getCircumstance()
{
return $this->circumstance;
}
/**
* Set degradation
*
* @param string $degradation
*
* @return ComplaintLetter
*/
public function setDegradation($degradation)
{
$this->degradation = $degradation;
return $this;
}
/**
* Get degradation
*
* @return string
*/
public function getDegradation()
{
return $this->degradation;
}
/**
* Set evaluation
*
* @param string $evaluation
*
* @return ComplaintLetter
*/
public function setEvaluation($evaluation)
{
$this->evaluation = $evaluation;
return $this;
}
/**
* Get evaluation
*
* @return string
*/
public function getEvaluation()
{
return $this->evaluation;
}
/**
* Set insurance
*
* @param \App\Entity\Insurance $insurance
*
* @return ComplaintLetter
*/
public function setInsurance(\App\Entity\Insurance $insurance)
{
$this->insurance = $insurance;
return $this;
}
/**
* Get insurance
*
* @return \App\Entity\Insurance
*/
public function getInsurance()
{
return $this->insurance;
}
/**
* Add item
*
* @param \App\Entity\Item $item
*
* @return ComplaintLetter
*/
public function addItem(\App\Entity\Item $item)
{
$this->items[] = $item;
return $this;
}
/**
* Remove item
*
* @param \App\Entity\Item $item
*/
public function removeItem(\App\Entity\Item $item)
{
$this->items->removeElement($item);
}
/**
* Get items
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getItems()
{
return $this->items;
}
/**
* Set user
*
* @param \App\Entity\User $user
*
* @return ComplaintLetter
*/
public function setUser(?\App\Entity\User $user)
{
$this->user = $user;
return $this;
}
/**
* Get user
*
* @return \App\Entity\User
*/
public function getUser()
{
return $this->user;
}
/**
* Add insuranceDisasterDeclaration
*
* @param \App\Entity\InsuranceDisasterDeclaration $insuranceDisasterDeclaration
*
* @return ComplaintLetter
*/
public function addInsuranceDisasterDeclaration(\App\Entity\InsuranceDisasterDeclaration $insuranceDisasterDeclaration)
{
$this->insuranceDisasterDeclarations[] = $insuranceDisasterDeclaration;
return $this;
}
/**
* Remove insuranceDisasterDeclaration
*
* @param \App\Entity\InsuranceDisasterDeclaration $insuranceDisasterDeclaration
*/
public function removeInsuranceDisasterDeclaration(\App\Entity\InsuranceDisasterDeclaration $insuranceDisasterDeclaration)
{
$this->insuranceDisasterDeclarations->removeElement($insuranceDisasterDeclaration);
}
/**
* Get insuranceDisasterDeclarations
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getInsuranceDisasterDeclarations()
{
return $this->insuranceDisasterDeclarations;
}
/**
* Add charge
*
* @param \App\Entity\Charge $charge
*
* @return ComplaintLetter
*/
public function addCharge(\App\Entity\Charge $charge)
{
$this->charges[] = $charge;
return $this;
}
/**
* Remove charge
*
* @param \App\Entity\Charge $charge
*/
public function removeCharge(\App\Entity\Charge $charge)
{
$this->charges->removeElement($charge);
}
/**
* Get charges
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getCharges()
{
return $this->charges;
}
/**
* Set createdAt
*
* @param DateTime $createdAt
*
* @return ComplaintLetter
*/
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
/**
* Get createdAt
*
* @return DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Set isDeleted
*
* @param boolean $isDeleted
*
* @return ComplaintLetter
*/
public function setIsDeleted($isDeleted)
{
$this->isDeleted = $isDeleted;
return $this;
}
/**
* Get isDeleted
*
* @return boolean
*/
public function getIsDeleted()
{
return $this->isDeleted;
}
}