src/Entity/InvoiceDetail.php line 46
<?php
namespace App\Entity;
use App\Repository\InvoiceDetailRepository;
use Doctrine\ORM\Mapping as ORM;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Put;
use Symfony\Component\Serializer\Annotation\Groups;
use App\Controller\Api\InvoiceController;
#[ORM\Entity(repositoryClass: InvoiceDetailRepository::class)]
#[ApiResource(
normalizationContext: ['groups' => ['invoiceDetail:read']],
denormalizationContext: ['groups' => ['invoiceDetail:write']],
operations: [
new Get(),
new Put(),
new Put(
name: 'update_invoice_details',
routeName: 'api_invoices_update_details',
controller: InvoiceController::class,
),
new Patch(security: 'is_granted("ROLE_SUPER_ADMIN") or is_granted("ROLE_ADMIN")'),
new Delete(),
new Delete(
name: 'delete_invoice_details',
routeName: 'api_invoices_delete_details',
controller: InvoiceController::class,
),
new GetCollection(),
new Post(),
new Post(
name: 'insert_invoice_details',
routeName: 'api_invoices_insert_details',
controller: InvoiceController::class,
),
],
paginationEnabled: false
)]
class InvoiceDetail
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['invoiceDetail:read', 'invoice:read'])]
private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'invoiceDetails')]
#[ORM\JoinColumn(nullable: false)]
#[Groups(['invoiceDetail:read', 'invoiceDetail:write'])]
private ?Invoice $invoice = null;
#[ORM\ManyToOne(inversedBy: 'invoiceDetails')]
#[ORM\JoinColumn(nullable: false)]
#[Groups(['invoiceDetail:read', 'invoiceDetail:write', 'invoice:read'])]
private ?Services $service = null;
#[ORM\Column]
#[Groups(['invoiceDetail:read', 'invoiceDetail:write', 'invoice:read'])]
private ?int $quantity = null;
#[ORM\Column(nullable: true)]
#[Groups(['invoiceDetail:read', 'invoiceDetail:write', 'invoice:read'])]
private ?float $value = null;
public function getId(): ?int
{
return $this->id;
}
public function getInvoice(): ?Invoice
{
return $this->invoice;
}
public function setInvoice(?Invoice $invoice): self
{
$this->invoice = $invoice;
return $this;
}
public function getService(): ?Services
{
return $this->service;
}
public function setService(?Services $service): self
{
$this->service = $service;
return $this;
}
public function getQuantity(): ?int
{
return $this->quantity;
}
public function setQuantity(int $quantity): self
{
$this->quantity = $quantity;
return $this;
}
public function getValue(): ?float
{
return $this->value;
}
public function setValue(?float $value): self
{
$this->value = $value;
return $this;
}
}