From 15f8db46a05ac4ccf091b6b18804e34ec05bc496 Mon Sep 17 00:00:00 2001 From: lubiana Date: Sun, 29 Jun 2025 19:47:46 +0200 Subject: [PATCH] lol --- config/packages/api_platform.yaml | 7 ---- config/routes/api_platform.yaml | 4 --- src/Entity/MenuItem.php | 16 +++++++++ src/Entity/OrderItem.php | 34 +++++++++++++++++++ .../Controller/OrderItemControllerTest.php | 2 +- 5 files changed, 51 insertions(+), 12 deletions(-) delete mode 100644 config/packages/api_platform.yaml delete mode 100644 config/routes/api_platform.yaml diff --git a/config/packages/api_platform.yaml b/config/packages/api_platform.yaml deleted file mode 100644 index 02f295a..0000000 --- a/config/packages/api_platform.yaml +++ /dev/null @@ -1,7 +0,0 @@ -api_platform: - title: Hello API Platform - version: 1.0.0 - defaults: - stateless: true - cache_headers: - vary: ['Content-Type', 'Authorization', 'Origin'] diff --git a/config/routes/api_platform.yaml b/config/routes/api_platform.yaml deleted file mode 100644 index 38f11cb..0000000 --- a/config/routes/api_platform.yaml +++ /dev/null @@ -1,4 +0,0 @@ -api_platform: - resource: . - type: api_platform - prefix: /api diff --git a/src/Entity/MenuItem.php b/src/Entity/MenuItem.php index 21beed9..bbea315 100644 --- a/src/Entity/MenuItem.php +++ b/src/Entity/MenuItem.php @@ -35,6 +35,11 @@ class MenuItem #[ORM\Column(length: 255)] private string|null $name = null; + #[ORM\Column(type: 'integer', options: [ + 'default' => 0, + ])] + private int $priceCents = 0; + public function __construct( #[ORM\Column(type: UlidType::NAME, unique: true)] #[ORM\CustomIdGenerator(class: UlidGenerator::class)] @@ -95,6 +100,11 @@ class MenuItem return $this->name; } + public function getPriceCents(): int + { + return $this->priceCents; + } + public function isDeleted(): bool { return $this->getDeletedAt() instanceof DateTimeImmutable; @@ -137,4 +147,10 @@ class MenuItem return $this; } + + public function setPriceCents(int $priceCents): self + { + $this->priceCents = $priceCents; + return $this; + } } diff --git a/src/Entity/OrderItem.php b/src/Entity/OrderItem.php index 5b2c045..b479a10 100644 --- a/src/Entity/OrderItem.php +++ b/src/Entity/OrderItem.php @@ -28,6 +28,12 @@ class OrderItem #[ORM\ManyToOne(inversedBy: 'orderItems')] private FoodOrder|null $foodOrder = null; + #[Groups('food_order:latest')] + #[ORM\Column(type: 'boolean', options: [ + 'default' => false, + ])] + private bool $isPaid = false; + #[Groups(['food_order:latest'])] #[ORM\JoinColumn(nullable: false)] #[ORM\ManyToOne] @@ -37,6 +43,12 @@ class OrderItem #[ORM\Column(length: 255)] private string|null $name = null; + #[Groups('food_order:latest')] + #[ORM\Column(type: 'integer', options: [ + 'default' => 0, + ])] + private int $priceCents = 0; + public function __construct( #[Groups(['food_order:latest'])] #[ORM\Column(type: UlidType::NAME, unique: true)] @@ -78,6 +90,16 @@ class OrderItem return $this->name; } + public function getPriceCents(): int + { + return $this->priceCents; + } + + public function isPaid(): bool + { + return $this->isPaid; + } + public function setCreatedBy(string $createdBy): static { $this->createdBy = $createdBy; @@ -99,6 +121,12 @@ class OrderItem return $this; } + public function setIsPaid(bool $isPaid): self + { + $this->isPaid = $isPaid; + return $this; + } + public function setMenuItem(MenuItem|null $menuItem): static { $this->menuItem = $menuItem; @@ -113,4 +141,10 @@ class OrderItem return $this; } + + public function setPriceCents(int $priceCents): self + { + $this->priceCents = $priceCents; + return $this; + } } diff --git a/tests/Feature/Controller/OrderItemControllerTest.php b/tests/Feature/Controller/OrderItemControllerTest.php index afbed56..d321553 100644 --- a/tests/Feature/Controller/OrderItemControllerTest.php +++ b/tests/Feature/Controller/OrderItemControllerTest.php @@ -182,7 +182,7 @@ describe(OrderItemController::class, function (): void { $this->assertResponseRedirects(sprintf('/food/order/%s', $this->order->getId())); $this->assertSame(1, $this->repository->count([])); - $this->assertSame(3, $this->menuItemRepository->count([])); + $this->assertSame(2, $this->menuItemRepository->count([])); });