src/Entity/InvoiceDetail.php line 46

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\InvoiceDetailRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use ApiPlatform\Metadata\ApiResource;
  6. use ApiPlatform\Metadata\Get;
  7. use ApiPlatform\Metadata\GetCollection;
  8. use ApiPlatform\Metadata\Delete;
  9. use ApiPlatform\Metadata\Post;
  10. use ApiPlatform\Metadata\Patch;
  11. use ApiPlatform\Metadata\Put;
  12. use Symfony\Component\Serializer\Annotation\Groups;
  13. use App\Controller\Api\InvoiceController;
  14. #[ORM\Entity(repositoryClassInvoiceDetailRepository::class)]
  15. #[ApiResource(
  16.     normalizationContext: ['groups' => ['invoiceDetail:read']],
  17.     denormalizationContext: ['groups' => ['invoiceDetail:write']],
  18.     operations: [
  19.         new Get(),
  20.         new Put(),
  21.         new Put(
  22.             name'update_invoice_details',
  23.             routeName'api_invoices_update_details',
  24.             controllerInvoiceController::class,
  25.         ),
  26.         new Patch(security'is_granted("ROLE_SUPER_ADMIN") or is_granted("ROLE_ADMIN")'),
  27.         new Delete(),
  28.         new Delete(
  29.             name'delete_invoice_details',
  30.             routeName'api_invoices_delete_details',
  31.             controllerInvoiceController::class,
  32.         ),
  33.         new GetCollection(),
  34.         new Post(),
  35.         new Post(
  36.             name'insert_invoice_details',
  37.             routeName'api_invoices_insert_details',
  38.             controllerInvoiceController::class,
  39.         ),
  40.     ],
  41.     paginationEnabledfalse
  42. )]
  43. class InvoiceDetail
  44. {
  45.     #[ORM\Id]
  46.     #[ORM\GeneratedValue]
  47.     #[ORM\Column]
  48.     #[Groups(['invoiceDetail:read''invoice:read'])]
  49.     private ?int $id null;
  50.     #[ORM\ManyToOne(inversedBy'invoiceDetails')]
  51.     #[ORM\JoinColumn(nullablefalse)]
  52.     #[Groups(['invoiceDetail:read''invoiceDetail:write'])]
  53.     private ?Invoice $invoice null;
  54.     #[ORM\ManyToOne(inversedBy'invoiceDetails')]
  55.     #[ORM\JoinColumn(nullablefalse)]
  56.     #[Groups(['invoiceDetail:read''invoiceDetail:write''invoice:read'])]
  57.     private ?Services $service null;
  58.     #[ORM\Column]
  59.     #[Groups(['invoiceDetail:read''invoiceDetail:write''invoice:read'])]
  60.     private ?int $quantity null;
  61.     #[ORM\Column(nullabletrue)]
  62.     #[Groups(['invoiceDetail:read''invoiceDetail:write''invoice:read'])]
  63.     private ?float $value null;
  64.     public function getId(): ?int
  65.     {
  66.         return $this->id;
  67.     }
  68.     public function getInvoice(): ?Invoice
  69.     {
  70.         return $this->invoice;
  71.     }
  72.     public function setInvoice(?Invoice $invoice): self
  73.     {
  74.         $this->invoice $invoice;
  75.         return $this;
  76.     }
  77.     public function getService(): ?Services
  78.     {
  79.         return $this->service;
  80.     }
  81.     public function setService(?Services $service): self
  82.     {
  83.         $this->service $service;
  84.         return $this;
  85.     }
  86.     public function getQuantity(): ?int
  87.     {
  88.         return $this->quantity;
  89.     }
  90.     public function setQuantity(int $quantity): self
  91.     {
  92.         $this->quantity $quantity;
  93.         return $this;
  94.     }
  95.     public function getValue(): ?float
  96.     {
  97.         return $this->value;
  98.     }
  99.     public function setValue(?float $value): self
  100.     {
  101.         $this->value $value;
  102.         return $this;
  103.     }
  104. }