src/Controller/DestinationsController.php line 48

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Destinations;
  4. use Symfony\Component\Routing\Annotation\Route;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use App\Repository\DestinationsRepository;
  7. use Symfony\Component\HttpFoundation\Response;
  8. class DestinationsController extends AbstractController
  9. {
  10.     /**
  11.      * @Route("/destinations", name="destinations")
  12.      */
  13.     public function index()
  14.     {
  15.         $repository=$this->getDoctrine()->getRepository(Destinations::class);
  16.         $destinations=$repository->findAll();
  17.         return $this->render('destinations/index.html.twig', [
  18.             'destinations' => $destinations
  19.         ]);
  20.     }
  21.     /** 
  22.  * @Route("/destinations/{pays}", name="destination_show") 
  23.  */
  24. public function show($pays)
  25.    $pay=str_replace('-',' ',$pays);
  26.     $destination$this->getDoctrine()->getRepository(Destinations::class) ->findOneBy(['pays'=>$pay]);
  27.     // dd($destination);
  28. //    foreach($dest as $des)
  29. //    {
  30. //        $id=$des->getId();
  31. //    }
  32. //    $destination= $this->getDoctrine()->getRepository(Destinations::class)->find($id);
  33. //    dd($destination);
  34.     return $this->render('destinations/show.html.twig', array('destination' => $destination)
  35. );
  36. }
  37. }