src/Controller/MagasinsController.php line 21

  1. <?php
  2. namespace App\Controller;
  3. use App\Repository\MagasinRepository;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. class MagasinsController extends AbstractController
  8. {
  9.     private $magasinRepository;
  10.     public function __construct(MagasinRepository $magasinRepository) {
  11.         $this->magasinRepository $magasinRepository;
  12.     }
  13.     #[Route('/magasins'name'app_magasins')]
  14.     public function index(): Response
  15.     {
  16.         $magasin $this->magasinRepository->findAll();
  17.         return $this->render('magasins/index.html.twig', [
  18.             "magasins" => $magasin
  19.         ]);
  20.     }
  21.     #[Route('magasins/{slug}'name'magasins_details')]
  22.     public function details($slug): Response
  23.     {
  24.          $magasin $this->magasinRepository->findOneBy(['slug' => $slug]);
  25.          
  26.         return $this->render('magasins/details.html.twig', [
  27.             'magasins' => $magasin,
  28.         ]);
  29.     }
  30. }