<?php
namespace App\Entity;
use App\Repository\LossReportRepository;
use DateTime;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: LossReportRepository::class)]
#[ORM\Table(name: 'loss_report')]
class LossReport {
#[ORM\Column(type: 'boolean')]
private bool $isDeleted = false;
#[ORM\Column(name: 'createdAt', type: 'datetime')]
private DateTime $createdAt;
#[ORM\Id]
#[ORM\Column(name: 'id', type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private ?int $id;
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'lossReports')]
#[ORM\JoinColumn(nullable: false)]
private User $user;
#[ORM\ManyToMany(targetEntity: Item::class, inversedBy: 'lossReports')]
private Collection|array $items;
#[ORM\ManyToMany(targetEntity: PaymentMethod::class, inversedBy: 'lossReports')]
private Collection|array $paymentMethods;
#[ORM\Column(name: 'lossDate', type: 'datetimetz')]
private DateTime $lossDate;
#[ORM\Column(type: 'datetime', nullable: true)]
private DateTime $beginTime;
#[Assert\Expression("this.getEndTime() > this.getBeginTime()", message:"La fin de la plage horaire doit être après son début.")]
#[ORM\Column(type: 'datetime', nullable: true)]
private ?DateTime $endTime;
#[ORM\Column(name: 'lossCity', type: 'string', length: 255)]
private string $lossCity;
#[ORM\Column(name: 'placeType', type: 'string', length: 255)]
private string $placeType;
#[ORM\Column(name: 'detail', type: 'text', nullable: true)]
private ?string $detail;
public function __construct() {
$this->createdAt = new DateTime();
$this->items = new \Doctrine\Common\Collections\ArrayCollection();
$this->paymentMethods = new \Doctrine\Common\Collections\ArrayCollection();
}
public function __toString() {
return "#" . $this->id . " - " . $this->createdAt->format("d/m/Y H:i");
}
/**
*
*/
public static function getPlacesTypes(){
$arr = [
'Lieu de perte ignoré',
'Dans la rue',
'Dans les couloirs d\'une station de Métro',
'Dans les couloirs d\'une station de RER',
'Dans les transports en commun',
'Dans un aéroport',
'Dans un avion',
'Dans un bar',
'Dans un Bateau',
'Dans un bus "Urbain"',
'Dans un car "Grande ligne"',
'Dans un car de "voyage"',
'Dans un cinéma',
'Dans un espace privé',
'Dans un espace public',
'Dans un magasin',
'Dans un magasin "grande surface"',
'Dans un musée',
'Dans un restaurant',
'Dans un salon grand public',
'Dans un salon professionnel ',
'Dans un stade ',
'Dans un taxi',
'Dans un train "Grande ligne"',
'Dans un train "Intercités"',
'Dans un train "TER"',
'Dans un train "TGV"',
'Dans un train de banlieue "Transilien"',
'Dans un tramway',
'Dans un vestiaire sportif',
'dans un VTC',
'Dans une boutique',
'Dans une enceinte sportive',
'Dans une foire exposition',
'Dans une gare férroviaire ',
'Dans une gare maritime',
'Dans une gare routiére',
'Dans une rame "RER"',
'Dans une rame de "Métro"',
'Devant un collège',
'Devant un lycée ',
'Devant une école',
'Lors d’un concert',
'Lors d’un match',
'Lors d’un spectacle',
'Lors d’une exposition',
'Sur la terrasse d’un bar',
'Sur la terrasse d’un commerce',
'Sur la terrasse d’un restaurant',
'Sur le marché',
'Sur mon lieu de travail ',
];
return array_combine($arr, $arr);
}
/**
* Get id
*
* @return int
*/
public function getId() {
return $this->id;
}
/**
* Set lossDate
*
* @param DateTime $lossDate
*
* @return LossReport
*/
public function setLossDate($lossDate) {
$this->lossDate = $lossDate;
return $this;
}
/**
* Get lossDate
*
* @return DateTime
*/
public function getLossDate() {
return $this->lossDate;
}
/**
* Set lossCity
*
* @param string $lossCity
*
* @return LossReport
*/
public function setLossCity($lossCity) {
$this->lossCity = $lossCity;
return $this;
}
/**
* Get lossCity
*
* @return string
*/
public function getLossCity() {
return $this->lossCity;
}
/**
* Set placeType
*
* @param string $placeType
*
* @return LossReport
*/
public function setPlaceType($placeType) {
$this->placeType = $placeType;
return $this;
}
/**
* Get placeType
*
* @return string
*/
public function getPlaceType() {
return $this->placeType;
}
/**
* Set detail
*
* @param string $detail
*
* @return LossReport
*/
public function setDetail($detail) {
$this->detail = $detail;
return $this;
}
/**
* Get detail
*
* @return string
*/
public function getDetail() {
return $this->detail;
}
/**
* Set user
*
* @param \App\Entity\User $user
*
* @return LossReport
*/
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 item
*
* @param \App\Entity\Item $item
*
* @return LossReport
*/
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;
}
/**
* Add paymentMethod
*
* @param \App\Entity\PaymentMethod $paymentMethod
*
* @return LossReport
*/
public function addPaymentMethod(\App\Entity\PaymentMethod $paymentMethod) {
$this->paymentMethods[] = $paymentMethod;
return $this;
}
/**
* Remove paymentMethod
*
* @param \App\Entity\PaymentMethod $paymentMethod
*/
public function removePaymentMethod(\App\Entity\PaymentMethod $paymentMethod) {
$this->paymentMethods->removeElement($paymentMethod);
}
/**
* Get paymentMethods
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getPaymentMethods() {
return $this->paymentMethods;
}
/**
* Set createdAt
*
* @param DateTime $createdAt
*
* @return LossReport
*/
public function setCreatedAt($createdAt) {
$this->createdAt = $createdAt;
return $this;
}
/**
* Get createdAt
*
* @return DateTime
*/
public function getCreatedAt() {
return $this->createdAt;
}
/**
* Set beginTime
*
* @param DateTime $beginTime
*
* @return LossReport
*/
public function setBeginTime($beginTime) {
$this->beginTime = $beginTime;
return $this;
}
/**
* Get beginTime
*
* @return DateTime
*/
public function getBeginTime() {
return $this->beginTime;
}
/**
* Set endTime
*
* @param DateTime $endTime
*
* @return LossReport
*/
public function setEndTime($endTime) {
$this->endTime = $endTime;
return $this;
}
/**
* Get endTime
*
* @return DateTime
*/
public function getEndTime() {
return $this->endTime;
}
/**
* Set isDeleted
*
* @param boolean $isDeleted
*
* @return LossReport
*/
public function setIsDeleted($isDeleted)
{
$this->isDeleted = $isDeleted;
return $this;
}
/**
* Get isDeleted
*
* @return boolean
*/
public function getIsDeleted()
{
return $this->isDeleted;
}
}