<?php
namespace App\Controller;
use App\Entity\Blog;
use App\Entity\Post;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use Doctrine\Persistence\ManagerRegistry;
class BlogController extends AbstractController
{
public function index(ManagerRegistry $doctrine)
{
$blog = $doctrine->getRepository(Blog::class)->findBy(array(), array('id' => 'desc'));
$blog_new = $doctrine->getRepository(Blog::class)->findBy(array(), array('id' => 'desc'),6,0);
return $this->render('blog/index.html.twig',['blog'=>$blog,'blog_new'=>$blog_new]);
}
public function detail(ManagerRegistry $doctrine,$id,$name)
{
$blog = $doctrine->getRepository(Blog::class)->find($id);
$blog_new = $doctrine->getRepository(Blog::class)->findBy(array(), array('id' => 'desc'),6,0);
return $this->render('blog/detail.html.twig',['key'=>$blog,'blog_new'=>$blog_new,'id'=>$id]);
}
}