<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: ChargeRepository::class)]
#[ORM\Table(name: "charge")]
class Charge
{
#[ORM\Id]
#[ORM\GeneratedValue(strategy: "AUTO")]
#[ORM\Column(type: "integer")]
private ?int $id = null;
#[ORM\Column(type: "datetime")]
private \DateTimeInterface $createdAt;
#[ORM\Column(type: "boolean")]
private bool $isDeleted = false;
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: "charges", cascade: ["persist"])]
#[ORM\JoinColumn(nullable: false)]
private ?User $user;
#[ORM\Column(type: "string", length: 255)]
#[Assert\Choice(callback: "getTypes", multiple: false)]
private ?string $type;
#[ORM\ManyToOne(targetEntity: DisasterDeclaration::class, inversedBy: "charges", cascade: ["persist"])]
#[ORM\JoinColumn(nullable: true)]
private ?DisasterDeclaration $disasterDeclaration;
#[ORM\ManyToOne(targetEntity: ComplaintLetter::class, inversedBy: "charges", cascade: ["persist"])]
#[ORM\JoinColumn(nullable: true)]
private ?ComplaintLetter $complaintLetter;
#[ORM\ManyToOne(targetEntity: Steal::class, inversedBy: "charges", cascade: ["persist"])]
#[ORM\JoinColumn(nullable: true)]
private ?Steal $steal;
#[ORM\Column(type: "integer")]
private int $amount;
public function __construct()
{
$this->createdAt = new \DateTime();
}
public function __toString(): string
{
return "#" . $this->id . " - " . $this->amount;
}
public static function getTypes(): array
{
return [
"disaster_declaration_routing",
"steal_routing",
"complaint_letter_routing",
];
}
public function getId(): ?int
{
return $this->id;
}
public function getIsDeleted(): bool
{
return $this->isDeleted;
}
public function setIsDeleted(bool $isDeleted): self
{
$this->isDeleted = $isDeleted;
return $this;
}
public function getType(): string
{
return $this->type;
}
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
public function getAmount(): int
{
return $this->amount;
}
public function setAmount(int $amount): self
{
$this->amount = $amount;
return $this;
}
public function getCreatedAt(): \DateTimeInterface
{
return $this->createdAt;
}
public function getUser(): User
{
return $this->user;
}
public function setUser(User $user): self
{
$this->user = $user;
return $this;
}
public function getDisasterDeclaration(): ?DisasterDeclaration
{
return $this->disasterDeclaration;
}
public function setDisasterDeclaration(?DisasterDeclaration $disasterDeclaration): self
{
$this->disasterDeclaration = $disasterDeclaration;
return $this;
}
public function getSteal(): ?Steal
{
return $this->steal;
}
public function setSteal(?Steal $steal): self
{
$this->steal = $steal;
return $this;
}
public function getComplaintLetter(): ?ComplaintLetter
{
return $this->complaintLetter;
}
public function setComplaintLetter(?ComplaintLetter $complaintLetter): self
{
$this->complaintLetter = $complaintLetter;
return $this;
}
}