51 lines
1.5 KiB
PHP
51 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Controller\Admin\AccommodationBooking;
|
|
|
|
use App\Repository\Groups\AccommodationBookingRepository;
|
|
use Knp\Component\Pager\PaginatorInterface;
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Symfony\Component\Routing\Attribute\Route;
|
|
|
|
class IndexController extends AbstractController
|
|
{
|
|
public function __construct(
|
|
private readonly AccommodationBookingRepository $bookingRepository,
|
|
private readonly PaginatorInterface $paginator,
|
|
) {
|
|
}
|
|
|
|
#[Route('/admin/accommodation-booking', name: 'app_admin_accommodationbooking')]
|
|
public function index(Request $request): Response
|
|
{
|
|
$today = new \DateTimeImmutable('today');
|
|
|
|
$qb = $this
|
|
->bookingRepository
|
|
->createQueryBuilder('booking')
|
|
->leftJoin('booking.accommodation', 'accommodation')
|
|
->addSelect('accommodation')
|
|
->where('booking.dateTo >= :today')
|
|
->setParameter('today', $today)
|
|
;
|
|
|
|
$pagination = $this->paginator->paginate(
|
|
$qb,
|
|
$request->query->getInt('page', 1),
|
|
$request->query->getInt('limit', 20),
|
|
[
|
|
'defaultSortFieldName' => 'booking.createdAt',
|
|
'defaultSortDirection' => 'DESC',
|
|
]
|
|
);
|
|
|
|
return $this->render('admin/accommodation_booking/index.html.twig', [
|
|
'pagination' => $pagination,
|
|
]);
|
|
}
|
|
}
|