added a /api/food_orders/latest/ endpoint to recieve the latest food order
This commit is contained in:
parent
ee32852789
commit
300c8cafc9
4 changed files with 64 additions and 0 deletions
22
src/State/LatestOrderProvider.php
Normal file
22
src/State/LatestOrderProvider.php
Normal 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();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue