ShowroomController
Код: Выделить всё
#[Route('/membre/{id}/showroom', name: 'app_showroom_index', methods: ['GET'])]
public function index(int $id, MembreRepository $membreRepository): Response
{
// Récupérer le membre via son ID
$membre = $membreRepository->find($id);
if (!$membre) {
throw $this->createNotFoundException('Membre introuvable.');
}
// Afficher l'ID du membre avec dump()
dump($membre->getId()); // ou dump($id) pour afficher directement l'ID reçu dans l'argument
// Récupérer les showrooms associés au membre via la relation
$showrooms = $membre->getShowrooms();
dump($showrooms->first());
return $this->render('showroom/index.html.twig', [
'showrooms' => $showrooms,
]);
}
Код: Выделить всё
class MembreController extends AbstractController
{
#[Route('/membre', name: 'app_membre_index', methods: ['GET'])]
public function index(MembreRepository $membreRepository): Response
{
$membres = $membreRepository->findAll();
return $this->render('membre/index.html.twig', [
'membres' => $membres,
]);
}
Код: Выделить всё
{% extends 'base.html.twig' %}
{% block title %}
Liste des membres
{% endblock %}
{% block body %}
Liste des membres
Id
email
roles
{% for membre in membres %}
{{ membre.id }}
{{ membre.email }}
{% for role in membre.roles %}
{{ role }}
[url={{ path(]
Voir la fiche du membre [/url]
{{ dump(membre.id) }}
{{ dump('test') }} {# Vérifiez si 'test' s'affiche dans la barre de débogage #}
[url={{ path(]Voir les showrooms[/url]
{% endfor %}
{% endfor %}
{% endblock %}
Код: Выделить всё
{% extends 'base.html.twig' %}
{% block title %}Showroom index{% endblock %}
{% block body %}
Showroom index
Id
Description
Publiee
actions
{% for showroom in showrooms %}
{{ showroom.id }}
{{ showroom.description }}
{{ showroom.publiee ? 'Yes' : 'No' }}
[url={{ path(]show[/url]
[url={{ path(]edit[/url]
{% else %}
no records found
{% endfor %}
[url={{ path(]Create new[/url]
{% endblock %}
Подробнее здесь: https://stackoverflow.com/questions/791 ... plate-some
Мобильная версия