<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\FeesRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
#[ORM\Entity(repositoryClass: FeesRepository::class)]
#[ApiResource(
normalizationContext: ['groups' => ['fees:read']],
denormalizationContext: ['groups' => ['fees:write']],
order: ['id' => 'DESC'],
)]
class Fees
{
#[Groups(['fees:read', 'fees:write', 'pre_order:read'])]
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[Groups(['fees:read', 'fees:write', 'pre_order:read'])]
#[ORM\Column(length: 255)]
private ?string $name = null;
#[Groups(['fees:read', 'fees:write', 'pre_order:read'])]
#[ORM\Column(nullable: true)]
private ?float $sum = null;
#[Groups(['fees:read', 'fees:write', 'pre_order:read'])]
#[ORM\Column(nullable: true)]
private ?float $percent = null;
#[Groups(['fees:read', 'fees:write', 'pre_order:read'])]
#[ORM\Column(length: 100, nullable: true)]
private ?string $status = null;
#[Groups(['fees:read', 'fees:write', 'pre_order:read'])]
#[ORM\Column(length: 100, nullable: true)]
private ?string $type = null;
#[Groups(['fees:read', 'fees:write'])]
#[ORM\ManyToMany(targetEntity: PreOrder::class, inversedBy: 'fees')]
private Collection $pre_orders;
public function __construct()
{
$this->pre_orders = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getSum(): ?float
{
return $this->sum;
}
public function setSum(?float $sum): self
{
$this->sum = $sum;
return $this;
}
public function getPercent(): ?float
{
return $this->percent;
}
public function setPercent(?float $percent): self
{
$this->percent = $percent;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(?string $status): self
{
$this->status = $status;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): self
{
$this->type = $type;
return $this;
}
/**
* @return Collection<int, PreOrder>
*/
public function getPreOrders(): Collection
{
return $this->pre_orders;
}
public function addPreOrder(PreOrder $preOrder): self
{
if (!$this->pre_orders->contains($preOrder)) {
$this->pre_orders->add($preOrder);
}
return $this;
}
public function removePreOrder(PreOrder $preOrder): self
{
$this->pre_orders->removeElement($preOrder);
return $this;
}
}