<?php
namespace App\Controller;
use App\Entity\Destinations;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use App\Repository\DestinationsRepository;
use Symfony\Component\HttpFoundation\Response;
class DestinationsController extends AbstractController
{
/**
* @Route("/destinations", name="destinations")
*/
public function index()
{
$repository=$this->getDoctrine()->getRepository(Destinations::class);
$destinations=$repository->findAll();
return $this->render('destinations/index.html.twig', [
'destinations' => $destinations
]);
}
/**
* @Route("/destinations/{pays}", name="destination_show")
*/
public function show($pays)
{
$pay=str_replace('-',' ',$pays);
$destination= $this->getDoctrine()->getRepository(Destinations::class) ->findOneBy(['pays'=>$pay]);
// dd($destination);
// foreach($dest as $des)
// {
// $id=$des->getId();
// }
// $destination= $this->getDoctrine()->getRepository(Destinations::class)->find($id);
// dd($destination);
return $this->render('destinations/show.html.twig', array('destination' => $destination)
);
}
}