Findby DateTime the recent uploaded articles Symfony

Hello im triying to get on my dashboard only the most recent articles
but isnt working i did this function

public function PostsRecientes(){
    return $this->getEntityManager()
    ->createQuery('        
    SELECT post
    FROM App:Posts post 
    WHERE post.fechaPublicacion > CURRENT_DATE()')
    ->getResult();
}

and this in my dashboardcontroller

/**
 * @Route("/", name="dashboard")
 */
public function index(PaginatorInterface $paginator, Request $request): Response
{
    
    $em = $this->getDoctrine()->getManager();
    $posts = $em->getRepository(Posts::class)->PostsRecientes();
    return $this->render('dashboard/index.html.twig', [
        'posts' => $posts
    ]);
}

but when i do a var dump i doesnt bring any post.

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *