<?php
namespace App\Controller;
use App\Entity\Posts;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Knp\Component\Pager\PaginatorInterface;
class DashboardController extends AbstractController
{
#[Route('/', name: 'app_dashboard')]
public function index(PaginatorInterface $paginator, Request $request): Response
{
$em = $this->getDoctrine()->getManager();
$query = $em->getRepository(Posts::class)->buscarTodosLosPosts();
$pagination = $paginator->paginate(
$query, /* query NOT result */
$request->query->getInt('page', 1), /*page number*/
3 /*limit per page*/
);
return $this->render('dashboard/index.html.twig', [
'pagination' => $pagination
]);
}
}