<?php
namespace App\Controller;
use App\Repository\PageRepository;
use App\Repository\PostRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class FrontController extends AbstractController
{
#[Route('/', name: 'front_homepage')]
public function index(PageRepository $pageRepository, PostRepository $postRepository): Response
{
$homepageContent = $pageRepository->findOneBy(['slug' => 'homepage']);
$latestPosts = $postRepository->findBy(['online' => true], ['createdAt' =>'ASC'], 6);
return $this->render('front/home.html.twig', [
'page' => $homepageContent,
'latestPosts' => $latestPosts,
]);
}
}