src/Controller/Frontend/ListPublikasiController.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Frontend;
  3. use App\Controller\Base\BaseController;
  4. use App\Entity\TInfografik;
  5. use App\Filter\TInfografikFilterType;
  6. use App\Repository\MKategoriDetailRepository;
  7. use App\Repository\MUrusanDetailRepository;
  8. use App\Repository\TDokumenRepository;
  9. use Knp\Component\Pager\PaginatorInterface;
  10. use Symfony\Component\HttpFoundation\Request;
  11. use Symfony\Component\HttpFoundation\Response;
  12. use Symfony\Component\Routing\Annotation\Route;
  13. use Sonata\SeoBundle\Seo\SeoPageInterface;
  14. class ListPublikasiController extends BaseController
  15. {
  16.     /**
  17.      * @Route("/list-publikasi", name="list-publikasi")
  18.      */
  19.     public function index(SeoPageInterface $seoPageTDokumenRepository $tDokumenRepoMKategoriDetailRepository $mKategoriDetailRepoMUrusanDetailRepository $mUrusanDetailRepository,
  20.     PaginatorInterface $paginatorInterfaceRequest $request): Response
  21.     {
  22.         $seoPage->addTitlePrefix("Daftar Rilis Publikasi");
  23.         
  24.         // Set tahun yang diinginkan
  25.         $year 2023;
  26.         $startDate = new \DateTime("$year-01-01");
  27.         $endDate = new \DateTime(($year 1) . "-01-01");
  28.         $queryBuilder $this->getQueryBuilder(TInfografik::class)
  29.             ->andWhere("this.is_arsip = false")
  30.             ->andWhere("lower(this.judul) LIKE lower(:judul)")
  31.             ->andWhere("this.release_date >= :startDate")
  32.             ->andWhere("this.release_date < :endDate")
  33.             ->setParameter('judul''%' $request->get('judul''') . '%')
  34.             ->setParameter('startDate'$startDate)
  35.             ->setParameter('endDate'$endDate)
  36.             ->addOrderBy('this.release_date''desc');
  37.         $pagination $paginatorInterface->paginate($queryBuilder$request->query->getInt('page'1), 10);
  38.         $filter TInfografikFilterType::class;
  39.         $classInfo =  TInfografik::class;
  40.         $form $this->get('form.factory')->create($filter$this->getFilters($filter));
  41.         $queryBuilder $this->getQueryBuilder($classInfo);
  42.         $queryBuilder $this->buildFilter($request$form$queryBuilder)->addOrderBy("this.id""DESC");
  43.         dump($pagination);
  44.         return $this->render('frontend/list_publikasi/index.html.twig', [
  45.             'pagination' => $pagination,
  46.             'search' => array('judul'=>$request->get('judul''')),
  47.             'page_name' => 'list_publikasi',
  48.             'filter' => $form->createView(),
  49.         ]);
  50.     }
  51. }