forked from lubiana/futtern
41 lines
953 B
PHP
41 lines
953 B
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace App\Repository;
|
|
|
|
use App\Entity\FoodOrder;
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
use Doctrine\Persistence\ManagerRegistry;
|
|
|
|
/**
|
|
* @extends ServiceEntityRepository<FoodOrder>
|
|
*/
|
|
final class FoodOrderRepository extends ServiceEntityRepository
|
|
{
|
|
public function __construct(ManagerRegistry $registry)
|
|
{
|
|
parent::__construct($registry, FoodOrder::class);
|
|
}
|
|
|
|
public function save(FoodOrder $order): void
|
|
{
|
|
$this->getEntityManager()
|
|
->persist($order);
|
|
$this->getEntityManager()
|
|
->flush();
|
|
}
|
|
|
|
/**
|
|
* @return FoodOrder[]
|
|
*/
|
|
public function findLatestEntries(int $limit = 5): array
|
|
{
|
|
$qb = $this->createQueryBuilder('alias');
|
|
|
|
$qb->orderBy('alias.id', 'DESC');
|
|
$qb->setMaxResults($limit);
|
|
|
|
$query = $qb->getQuery();
|
|
|
|
return $query->getResult();
|
|
}
|
|
}
|