added a /api/food_orders/latest/ endpoint to recieve the latest food order
Some checks failed
/ ls (pull_request) Successful in 2m6s
/ ls (release) Successful in 1m18s
/ ls (push) Failing after 1m25s

This commit is contained in:
Jan Felix Wiebe 2025-06-17 21:26:05 +02:00
parent ee32852789
commit 300c8cafc9
4 changed files with 64 additions and 0 deletions

View file

@ -0,0 +1,22 @@
<?php declare(strict_types=1);
namespace App\State;
use ApiPlatform\Metadata\Operation;
use ApiPlatform\State\ProviderInterface;
use App\Entity\FoodOrder;
use App\Repository\FoodOrderRepository;
use Override;
final readonly class LatestOrderProvider implements ProviderInterface
{
public function __construct(
private FoodOrderRepository $repository
) {}
#[Override]
public function provide(Operation $operation, array $uriVariables = [], array $context = []): ?FoodOrder
{
return $this->repository->findLatestOrder();
}
}