connexion base et création premier crud

This commit is contained in:
Logshiro
2025-10-16 17:01:43 +02:00
parent ea9a187326
commit 2e4dce40d4
38 changed files with 653 additions and 278 deletions

2
.env
View File

@@ -32,7 +32,7 @@ DEFAULT_URI=http://localhost
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data_%kernel.environment%.db"
# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=8.0.32&charset=utf8mb4"
# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4"
DATABASE_URL="mysql://contrib_root:123abc@127.0.0.1:3306/contrib?serverVersion=8.0.32&charset=utf8mb4"
DATABASE_URL="mysql://contribA_root:123abc@127.0.0.1:3306/contribC?serverVersion=8.0.32&charset=utf8mb4"
###< doctrine/doctrine-bundle ###
###> symfony/messenger ###
# Choose one of the transports below

View File

@@ -0,0 +1,81 @@
<?php
namespace App\Controller;
use App\Entity\Contribution;
use App\Form\ContributionType;
use App\Repository\ContributionRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
#[Route('/contribution')]
final class ContributionController extends AbstractController
{
#[Route(name: 'app_contribution_index', methods: ['GET'])]
public function index(ContributionRepository $contributionRepository): Response
{
return $this->render('contribution/index.html.twig', [
'contributions' => $contributionRepository->findAll(),
]);
}
#[Route('/new', name: 'app_contribution_new', methods: ['GET', 'POST'])]
public function new(Request $request, EntityManagerInterface $entityManager): Response
{
$contribution = new Contribution();
$form = $this->createForm(ContributionType::class, $contribution);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$entityManager->persist($contribution);
$entityManager->flush();
return $this->redirectToRoute('app_contribution_index', [], Response::HTTP_SEE_OTHER);
}
return $this->render('contribution/new.html.twig', [
'contribution' => $contribution,
'form' => $form,
]);
}
#[Route('/{id}', name: 'app_contribution_show', methods: ['GET'])]
public function show(Contribution $contribution): Response
{
return $this->render('contribution/show.html.twig', [
'contribution' => $contribution,
]);
}
#[Route('/{id}/edit', name: 'app_contribution_edit', methods: ['GET', 'POST'])]
public function edit(Request $request, Contribution $contribution, EntityManagerInterface $entityManager): Response
{
$form = $this->createForm(ContributionType::class, $contribution);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$entityManager->flush();
return $this->redirectToRoute('app_contribution_index', [], Response::HTTP_SEE_OTHER);
}
return $this->render('contribution/edit.html.twig', [
'contribution' => $contribution,
'form' => $form,
]);
}
#[Route('/{id}', name: 'app_contribution_delete', methods: ['POST'])]
public function delete(Request $request, Contribution $contribution, EntityManagerInterface $entityManager): Response
{
if ($this->isCsrfTokenValid('delete'.$contribution->getId(), $request->getPayload()->getString('_token'))) {
$entityManager->remove($contribution);
$entityManager->flush();
}
return $this->redirectToRoute('app_contribution_index', [], Response::HTTP_SEE_OTHER);
}
}

View File

@@ -3,7 +3,8 @@
namespace App\Controller;
use App\Entity\Membre;
use App\Form\MembreType;
use App\Form\Membre2Type;
use App\Repository\MembreRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
@@ -14,14 +15,10 @@ use Symfony\Component\Routing\Attribute\Route;
final class MembreController extends AbstractController
{
#[Route(name: 'app_membre_index', methods: ['GET'])]
public function index(EntityManagerInterface $entityManager): Response
public function index(MembreRepository $membreRepository): Response
{
$membres = $entityManager
->getRepository(Membre::class)
->findAll();
return $this->render('membre/index.html.twig', [
'membres' => $membres,
'membres' => $membreRepository->findAll(),
]);
}
@@ -29,7 +26,7 @@ final class MembreController extends AbstractController
public function new(Request $request, EntityManagerInterface $entityManager): Response
{
$membre = new Membre();
$form = $this->createForm(MembreType::class, $membre);
$form = $this->createForm(Membre2Type::class, $membre);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
@@ -56,7 +53,7 @@ final class MembreController extends AbstractController
#[Route('/{id}/edit', name: 'app_membre_edit', methods: ['GET', 'POST'])]
public function edit(Request $request, Membre $membre, EntityManagerInterface $entityManager): Response
{
$form = $this->createForm(MembreType::class, $membre);
$form = $this->createForm(Membre2Type::class, $membre);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {

View File

@@ -0,0 +1,84 @@
<?php
namespace App\Controller;
use App\Entity\Projet;
use App\Form\ProjetType;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
#[Route('/projet')]
final class ProjetController extends AbstractController
{
#[Route(name: 'app_projet_index', methods: ['GET'])]
public function index(EntityManagerInterface $entityManager): Response
{
$projets = $entityManager
->getRepository(Projet::class)
->findAll();
return $this->render('projet/index.html.twig', [
'projets' => $projets,
]);
}
#[Route('/new', name: 'app_projet_new', methods: ['GET', 'POST'])]
public function new(Request $request, EntityManagerInterface $entityManager): Response
{
$projet = new Projet();
$form = $this->createForm(ProjetType::class, $projet);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$entityManager->persist($projet);
$entityManager->flush();
return $this->redirectToRoute('app_projet_index', [], Response::HTTP_SEE_OTHER);
}
return $this->render('projet/new.html.twig', [
'projet' => $projet,
'form' => $form,
]);
}
#[Route('/{id}', name: 'app_projet_show', methods: ['GET'])]
public function show(Projet $projet): Response
{
return $this->render('projet/show.html.twig', [
'projet' => $projet,
]);
}
#[Route('/{id}/edit', name: 'app_projet_edit', methods: ['GET', 'POST'])]
public function edit(Request $request, Projet $projet, EntityManagerInterface $entityManager): Response
{
$form = $this->createForm(ProjetType::class, $projet);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$entityManager->flush();
return $this->redirectToRoute('app_projet_index', [], Response::HTTP_SEE_OTHER);
}
return $this->render('projet/edit.html.twig', [
'projet' => $projet,
'form' => $form,
]);
}
#[Route('/{id}', name: 'app_projet_delete', methods: ['POST'])]
public function delete(Request $request, Projet $projet, EntityManagerInterface $entityManager): Response
{
if ($this->isCsrfTokenValid('delete'.$projet->getId(), $request->getPayload()->getString('_token'))) {
$entityManager->remove($projet);
$entityManager->flush();
}
return $this->redirectToRoute('app_projet_index', [], Response::HTTP_SEE_OTHER);
}
}

View File

@@ -0,0 +1,65 @@
<?php
namespace App\Entity;
use App\Repository\ContributionRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ContributionRepository::class)]
class Contribution
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private ?int $id = null;
#[ORM\ManyToOne(targetEntity: Membre::class, inversedBy: 'contributions')]
#[ORM\JoinColumn(name: 'membre_id', referencedColumnName: 'id', nullable: false)]
private ?Membre $membre = null;
#[ORM\ManyToOne(targetEntity: Projet::class)]
#[ORM\JoinColumn(name: 'projet_id', referencedColumnName: 'id', nullable: false)]
private ?Projet $projet = null;
#[ORM\Column(type: 'integer', options: ['default' => 0])]
private ?int $duree = 0;
// Getters et Setters...
public function getId(): ?int
{
return $this->id;
}
public function getMembre(): ?Membre
{
return $this->membre;
}
public function setMembre(?Membre $membre): static
{
$this->membre = $membre;
return $this;
}
public function getProjet(): ?Projet
{
return $this->projet;
}
public function setProjet(?Projet $projet): static
{
$this->projet = $projet;
return $this;
}
public function getDuree(): ?int
{
return $this->duree;
}
public function setDuree(int $duree): static
{
$this->duree = $duree;
return $this;
}
}

View File

@@ -1,35 +0,0 @@
<?php
// src/Entity/Droit.php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
#[ORM\Table(name: "Droit")]
class Droit
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: "integer", name: "idDroit")]
private ?int $idDroit = null;
#[ORM\Column(type: "string", length: 30, name: "LibDroit")]
private ?string $libDroit = null;
// Getter et Setter
public function getIdDroit(): ?int
{
return $this->idDroit;
}
public function getLibDroit(): ?string
{
return $this->libDroit;
}
public function setLibDroit(string $libDroit): self
{
$this->libDroit = $libDroit;
return $this;
}
}

View File

@@ -1,37 +1,71 @@
<?php
// src/Entity/Membre.php
namespace App\Entity;
use App\Repository\MembreRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
#[ORM\Table(name: "Membre")]
#[ORM\Table(name: "membre")]
class Membre
{
#[ORM\Id]
#[ORM\Column(type: "string", length: 20)]
#[ORM\Column(type: 'string', length: 20)]
private ?string $id = null;
#[ORM\Column(type: "string", length: 50)]
#[ORM\Column(type: 'string', length: 50)]
private ?string $nom = null;
#[ORM\Column(type: "string", length: 100, nullable: true)]
#[ORM\Column(type: 'string', length: 100)]
private ?string $password = null;
#[ORM\ManyToOne(targetEntity: Droit::class)]
#[ORM\JoinColumn(name: "droit_id", referencedColumnName: "idDroit", nullable: true, onDelete: "SET NULL")]
private ?Droit $droit = null;
#[ORM\Column(type: 'string', length: 50, options: ['default' => 'dev'])]
private ?string $droit = 'dev';
// Getters et setters
public function getId(): ?string { return $this->id; }
public function setId(string $id): self { $this->id = $id; return $this; }
#[ORM\OneToMany(mappedBy: 'membre', targetEntity: Contribution::class)]
private Collection $contributions;
public function getNom(): ?string { return $this->nom; }
public function setNom(string $nom): self { $this->nom = $nom; return $this; }
public function getPassword(): ?string { return $this->password; }
public function setPassword(?string $password): self { $this->password = $password; return $this; }
public function getDroit(): ?Droit { return $this->droit; }
public function setDroit(?Droit $droit): self { $this->droit = $droit; return $this; }
public function __construct()
{
$this->contributions = new ArrayCollection();
}
// Getters et Setters...
public function getId(): ?string
{
return $this->id;
}
public function getNom(): ?string
{
return $this->nom;
}
public function setNom(string $nom): static
{
$this->nom = $nom;
return $this;
}
public function getPassword(): ?string
{
return $this->password;
}
public function setPassword(string $password): static
{
$this->password = $password;
return $this;
}
public function getDroit(): ?string
{
return $this->droit;
}
public function setDroit(string $droit): static
{
$this->droit = $droit;
return $this;
}
}

35
src/Entity/Projet.php Normal file
View File

@@ -0,0 +1,35 @@
<?php
namespace App\Entity;
use App\Repository\ProjetRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
#[ORM\Table(name: "projet")]
class Projet
{
#[ORM\Id]
#[ORM\Column(type: 'string', length: 20)]
private ?string $id = null;
#[ORM\Column(type: 'string', length: 50)]
private ?string $nom = null;
// Getters et Setters...
public function getId(): ?string
{
return $this->id;
}
public function getNom(): ?string
{
return $this->nom;
}
public function setNom(string $nom): static
{
$this->nom = $nom;
return $this;
}
}

View File

@@ -2,23 +2,26 @@
namespace App\Form;
use App\Entity\Droit;
use App\Entity\Contribution;
use App\Entity\Membre;
use App\Entity\Projet;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class Membre1Type extends AbstractType
class ContributionType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('id')
->add('nom')
->add('password')
->add('droit', EntityType::class, [
'class' => Droit::class,
->add('duree')
->add('membre', EntityType::class, [
'class' => Membre::class,
'choice_label' => 'id',
])
->add('projet', EntityType::class, [
'class' => Projet::class,
'choice_label' => 'id',
])
;
@@ -27,7 +30,7 @@ class Membre1Type extends AbstractType
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Membre::class,
'data_class' => Contribution::class,
]);
}
}

45
src/Form/Membre2Type.php Normal file
View File

@@ -0,0 +1,45 @@
<?php
namespace App\Form;
use App\Entity\Membre;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class Membre2Type extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('id')
->add('nom')
->add('plainPassword', PasswordType::class, [
'label' => 'Mot de passe',
'mapped' => false,
'required' => false,
'attr' => [
'placeholder' => 'Saisir le mot de passe',
],
])
->add('droit', ChoiceType::class, [
'label' => 'Droit',
'choices' => [
'dev' => 'dev',
'admin' => 'admin',
],
'placeholder' => 'Sélectionnez un droit',
'required' => true,
])
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Membre::class,
]);
}
}

View File

@@ -1,33 +0,0 @@
<?php
namespace App\Form;
use App\Entity\Droit;
use App\Entity\Membre;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class MembreType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('id')
->add('nom')
->add('password')
->add('droit', EntityType::class, [
'class' => Droit::class,
'choice_label' => 'id',
])
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Membre::class,
]);
}
}

View File

@@ -2,24 +2,25 @@
namespace App\Form;
use App\Entity\Droit;
use App\Entity\Projet;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class DroitType extends AbstractType
class ProjetType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('libDroit')
->add('id')
->add('nom')
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Droit::class,
'data_class' => Projet::class,
]);
}
}

View File

@@ -0,0 +1,13 @@
{#
Shared partial to include Bootstrap. Use with:
{{ include('_bootstrap.html.twig', { part: 'css' }) }} in the <head>
{{ include('_bootstrap.html.twig', { part: 'js' }) }} before closing </body>
#}
{% if part == 'css' %}
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
{% elseif part == 'js' %}
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
{% endif %}

View File

@@ -5,13 +5,17 @@
<title>{% block title %}Welcome!{% endblock %}</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 128 128%22><text y=%221.2em%22 font-size=%2296%22>⚫️</text><text y=%221.3em%22 x=%220.2em%22 font-size=%2276%22 fill=%22%23fff%22>sf</text></svg>">
{% block stylesheets %}
{{ include('_bootstrap.html.twig', { part: 'css' }) }}
{% endblock %}
{% block javascripts %}
{{ include('_bootstrap.html.twig', { part: 'js' }) }}
{% block importmap %}{{ importmap('app') }}{% endblock %}
{% endblock %}
</head>
<body>
<div class="container py-4">
{% block body %}{% endblock %}
</div>
</body>
</html>

View File

@@ -0,0 +1,4 @@
<form method="post" action="{{ path('app_contribution_delete', {'id': contribution.id}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');">
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ contribution.id) }}">
<button class="btn">Delete</button>
</form>

View File

@@ -0,0 +1,13 @@
{% extends 'base.html.twig' %}
{% block title %}Edit Contribution{% endblock %}
{% block body %}
<h1>Edit Contribution</h1>
{{ include('contribution/_form.html.twig', {'button_label': 'Update'}) }}
<a href="{{ path('app_contribution_index') }}">back to list</a>
{{ include('contribution/_delete_form.html.twig') }}
{% endblock %}

View File

@@ -0,0 +1,35 @@
{% extends 'base.html.twig' %}
{% block title %}Contribution index{% endblock %}
{% block body %}
<h1>Contribution index</h1>
<table class="table">
<thead>
<tr>
<th>Id</th>
<th>Duree</th>
<th>actions</th>
</tr>
</thead>
<tbody>
{% for contribution in contributions %}
<tr>
<td>{{ contribution.id }}</td>
<td>{{ contribution.duree }}</td>
<td>
<a href="{{ path('app_contribution_show', {'id': contribution.id}) }}">show</a>
<a href="{{ path('app_contribution_edit', {'id': contribution.id}) }}">edit</a>
</td>
</tr>
{% else %}
<tr>
<td colspan="3">no records found</td>
</tr>
{% endfor %}
</tbody>
</table>
<a href="{{ path('app_contribution_new') }}">Create new</a>
{% endblock %}

View File

@@ -0,0 +1,11 @@
{% extends 'base.html.twig' %}
{% block title %}New Contribution{% endblock %}
{% block body %}
<h1>Create new Contribution</h1>
{{ include('contribution/_form.html.twig') }}
<a href="{{ path('app_contribution_index') }}">back to list</a>
{% endblock %}

View File

@@ -0,0 +1,26 @@
{% extends 'base.html.twig' %}
{% block title %}Contribution{% endblock %}
{% block body %}
<h1>Contribution</h1>
<table class="table">
<tbody>
<tr>
<th>Id</th>
<td>{{ contribution.id }}</td>
</tr>
<tr>
<th>Duree</th>
<td>{{ contribution.duree }}</td>
</tr>
</tbody>
</table>
<a href="{{ path('app_contribution_index') }}">back to list</a>
<a href="{{ path('app_contribution_edit', {'id': contribution.id}) }}">edit</a>
{{ include('contribution/_delete_form.html.twig') }}
{% endblock %}

View File

@@ -1,4 +0,0 @@
<form method="post" action="{{ path('app_droit_delete', {'idDroit': droit.idDroit}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');">
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ droit.idDroit) }}">
<button class="btn">Delete</button>
</form>

View File

@@ -1,13 +0,0 @@
{% extends 'base.html.twig' %}
{% block title %}Edit Droit{% endblock %}
{% block body %}
<h1>Edit Droit</h1>
{{ include('droit/_form.html.twig', {'button_label': 'Update'}) }}
<a href="{{ path('app_droit_index') }}">back to list</a>
{{ include('droit/_delete_form.html.twig') }}
{% endblock %}

View File

@@ -1,35 +0,0 @@
{% extends 'base.html.twig' %}
{% block title %}Droit index{% endblock %}
{% block body %}
<h1>Droit index</h1>
<table class="table">
<thead>
<tr>
<th>IdDroit</th>
<th>LibDroit</th>
<th>actions</th>
</tr>
</thead>
<tbody>
{% for droit in droits %}
<tr>
<td>{{ droit.idDroit }}</td>
<td>{{ droit.libDroit }}</td>
<td>
<a href="{{ path('app_droit_show', {'idDroit': droit.idDroit}) }}">show</a>
<a href="{{ path('app_droit_edit', {'idDroit': droit.idDroit}) }}">edit</a>
</td>
</tr>
{% else %}
<tr>
<td colspan="3">no records found</td>
</tr>
{% endfor %}
</tbody>
</table>
<a href="{{ path('app_droit_new') }}">Create new</a>
{% endblock %}

View File

@@ -1,11 +0,0 @@
{% extends 'base.html.twig' %}
{% block title %}New Droit{% endblock %}
{% block body %}
<h1>Create new Droit</h1>
{{ include('droit/_form.html.twig') }}
<a href="{{ path('app_droit_index') }}">back to list</a>
{% endblock %}

View File

@@ -1,26 +0,0 @@
{% extends 'base.html.twig' %}
{% block title %}Droit{% endblock %}
{% block body %}
<h1>Droit</h1>
<table class="table">
<tbody>
<tr>
<th>IdDroit</th>
<td>{{ droit.idDroit }}</td>
</tr>
<tr>
<th>LibDroit</th>
<td>{{ droit.libDroit }}</td>
</tr>
</tbody>
</table>
<a href="{{ path('app_droit_index') }}">back to list</a>
<a href="{{ path('app_droit_edit', {'idDroit': droit.idDroit}) }}">edit</a>
{{ include('droit/_delete_form.html.twig') }}
{% endblock %}

View File

@@ -1,4 +1,4 @@
<form method="post" action="{{ path('app_membre_delete', {'id': membre.id}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');">
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ membre.id) }}">
<button class="btn">Delete</button>
<button class="btn btn-danger">Delete</button>
</form>

View File

@@ -1,4 +1,4 @@
{{ form_start(form) }}
{{ form_widget(form) }}
<button class="btn">{{ button_label|default('Save') }}</button>
<button class="btn btn-primary">{{ button_label|default('Save') }}</button>
{{ form_end(form) }}

View File

@@ -3,11 +3,16 @@
{% block title %}Edit Membre{% endblock %}
{% block body %}
<h1>Edit Membre</h1>
<div class="card mb-3">
<div class="card-header">
<h1 class="h4 mb-0">Edit Membre</h1>
</div>
<div class="card-body">
{{ include('membre/_form.html.twig', {'button_label': 'Update'}) }}
<a href="{{ path('app_membre_index') }}">back to list</a>
<div class="d-flex gap-2 mt-2">
<a href="{{ path('app_membre_index') }}" class="btn btn-outline-secondary">Back to list</a>
{{ include('membre/_delete_form.html.twig') }}
</div>
</div>
</div>
{% endblock %}

View File

@@ -2,23 +2,19 @@
{% block title %}Membre index{% endblock %}
{% block stylesheets %}
{{ parent() }}
{# Ajouter Bootstrap depuis le CDN #}
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
{% endblock %}
{% block body %}
<div class="container mt-4">
<h1 class="mb-4">Membre index</h1>
<div class="d-flex justify-content-between align-items-center mb-3">
<h1 class="h3 mb-0">Membres</h1>
<a href="{{ path('app_membre_new') }}" class="btn btn-success">Create new</a>
</div>
<table class="table table-striped table-bordered">
<thead class="table-dark">
<table class="table table-striped table-hover align-middle">
<thead>
<tr>
<th>Id</th>
<th>Nom</th>
<th>Password</th>
<th>Actions</th>
<th>Droit</th>
<th class="text-end">Actions</th>
</tr>
</thead>
<tbody>
@@ -26,20 +22,17 @@
<tr>
<td>{{ membre.id }}</td>
<td>{{ membre.nom }}</td>
<td>{{ membre.password }}</td>
<td>
<a href="{{ path('app_membre_show', {'id': membre.id}) }}" class="btn btn-sm btn-primary">Show</a>
<a href="{{ path('app_membre_edit', {'id': membre.id}) }}" class="btn btn-sm btn-warning">Edit</a>
<td>{{ membre.droit }}</td>
<td class="text-end">
<a href="{{ path('app_membre_show', {'id': membre.id}) }}" class="btn btn-sm btn-outline-primary me-1">Show</a>
<a href="{{ path('app_membre_edit', {'id': membre.id}) }}" class="btn btn-sm btn-outline-secondary">Edit</a>
</td>
</tr>
{% else %}
<tr>
<td colspan="4" class="text-center">No records found</td>
<td colspan="5" class="text-center text-muted">No records found</td>
</tr>
{% endfor %}
</tbody>
</table>
<a href="{{ path('app_membre_new') }}" class="btn btn-success">Create new</a>
</div>
{% endblock %}

View File

@@ -1,22 +0,0 @@
{# templates/membre/index.html.twig #}
<h1>Liste des Membres</h1>
<table border="1">
<thead>
<tr>
<th>ID</th>
<th>Nom</th>
<th>Droit</th>
</tr>
</thead>
<tbody>
{% for membre in membres %}
<tr>
<td>{{ membre.id }}</td>
<td>{{ membre.nom }}</td>
<td>{{ membre.droit ? membre.droit.nom : 'Aucun' }}</td>
</tr>
{% endfor %}
</tbody>
</table>

View File

@@ -3,9 +3,13 @@
{% block title %}New Membre{% endblock %}
{% block body %}
<h1>Create new Membre</h1>
<div class="card">
<div class="card-header">
<h1 class="h4 mb-0">Create new Membre</h1>
</div>
<div class="card-body">
{{ include('membre/_form.html.twig') }}
<a href="{{ path('app_membre_index') }}">back to list</a>
<a href="{{ path('app_membre_index') }}" class="btn btn-outline-secondary mt-2">Back to list</a>
</div>
</div>
{% endblock %}

View File

@@ -3,9 +3,15 @@
{% block title %}Membre{% endblock %}
{% block body %}
<h1>Membre</h1>
<div class="d-flex justify-content-between align-items-center mb-3">
<h1 class="h3 mb-0">Membre #{{ membre.id }}</h1>
<div>
<a href="{{ path('app_membre_edit', {'id': membre.id}) }}" class="btn btn-secondary me-2">Edit</a>
<a href="{{ path('app_membre_index') }}" class="btn btn-outline-secondary">Back to list</a>
</div>
</div>
<table class="table">
<table class="table table-bordered">
<tbody>
<tr>
<th>Id</th>
@@ -17,14 +23,16 @@
</tr>
<tr>
<th>Password</th>
<td>{{ membre.password }}</td>
<td>********</td>
</tr>
<tr>
<th>Droit</th>
<td>{{ membre.droit }}</td>
</tr>
</tbody>
</table>
<a href="{{ path('app_membre_index') }}">back to list</a>
<a href="{{ path('app_membre_edit', {'id': membre.id}) }}">edit</a>
<div class="mt-3">
{{ include('membre/_delete_form.html.twig') }}
</div>
{% endblock %}

View File

@@ -0,0 +1,4 @@
<form method="post" action="{{ path('app_projet_delete', {'id': projet.id}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');">
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ projet.id) }}">
<button class="btn">Delete</button>
</form>

View File

@@ -0,0 +1,4 @@
{{ form_start(form) }}
{{ form_widget(form) }}
<button class="btn">{{ button_label|default('Save') }}</button>
{{ form_end(form) }}

View File

@@ -0,0 +1,13 @@
{% extends 'base.html.twig' %}
{% block title %}Edit Projet{% endblock %}
{% block body %}
<h1>Edit Projet</h1>
{{ include('projet/_form.html.twig', {'button_label': 'Update'}) }}
<a href="{{ path('app_projet_index') }}">back to list</a>
{{ include('projet/_delete_form.html.twig') }}
{% endblock %}

View File

@@ -0,0 +1,35 @@
{% extends 'base.html.twig' %}
{% block title %}Projet index{% endblock %}
{% block body %}
<h1>Projet index</h1>
<table class="table">
<thead>
<tr>
<th>Id</th>
<th>Nom</th>
<th>actions</th>
</tr>
</thead>
<tbody>
{% for projet in projets %}
<tr>
<td>{{ projet.id }}</td>
<td>{{ projet.nom }}</td>
<td>
<a href="{{ path('app_projet_show', {'id': projet.id}) }}">show</a>
<a href="{{ path('app_projet_edit', {'id': projet.id}) }}">edit</a>
</td>
</tr>
{% else %}
<tr>
<td colspan="3">no records found</td>
</tr>
{% endfor %}
</tbody>
</table>
<a href="{{ path('app_projet_new') }}">Create new</a>
{% endblock %}

View File

@@ -0,0 +1,11 @@
{% extends 'base.html.twig' %}
{% block title %}New Projet{% endblock %}
{% block body %}
<h1>Create new Projet</h1>
{{ include('projet/_form.html.twig') }}
<a href="{{ path('app_projet_index') }}">back to list</a>
{% endblock %}

View File

@@ -0,0 +1,26 @@
{% extends 'base.html.twig' %}
{% block title %}Projet{% endblock %}
{% block body %}
<h1>Projet</h1>
<table class="table">
<tbody>
<tr>
<th>Id</th>
<td>{{ projet.id }}</td>
</tr>
<tr>
<th>Nom</th>
<td>{{ projet.nom }}</td>
</tr>
</tbody>
</table>
<a href="{{ path('app_projet_index') }}">back to list</a>
<a href="{{ path('app_projet_edit', {'id': projet.id}) }}">edit</a>
{{ include('projet/_delete_form.html.twig') }}
{% endblock %}