laisse la

This commit is contained in:
bourgoino 2024-11-28 16:58:42 +01:00
parent f8569d8db3
commit 432d7ba4de
4 changed files with 36 additions and 18 deletions

View File

@ -71,11 +71,14 @@ final class DegreeController extends AbstractController
#[Route('/{id}', name: 'app_degree_delete', methods: ['POST'])]
public function delete(Request $request, Degree $degree, EntityManagerInterface $entityManager): Response
{
if ($this->isCsrfTokenValid('delete'.$degree->getId(), $request->getPayload()->getString('_token'))) {
// Vérification du token CSRF pour la sécurité
if ($this->isCsrfTokenValid('delete'.$degree->getId(), $request->request->get('_token'))) {
// Suppression du diplôme
$entityManager->remove($degree);
$entityManager->flush();
}
return $this->redirectToRoute('app_degree_index', [], Response::HTTP_SEE_OTHER);
}
}

View File

@ -62,7 +62,7 @@ class Company
return $this;
}
public function getAddress(): ?string
public function getAddress(): ?stringz
{
return $this->address;
}

View File

@ -3,12 +3,18 @@
{% block title %}Bienvenue sur Hegreshpere{% endblock %}
{% block body %}
<script src="{{ asset('js/map.js') }}"></script>
<style>
.example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
.example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
#map {
height: 500px; /* Ajuste la taille selon tes besoins */
margin-bottom: 20px;
}
</style>
<h1> Liste des annonces</h1>
<div id="map"></div> <!-- Conteneur pour la carte -->
{% for ann in announcements %}
<h2> {{ ann.title }} </h2>
<h3> {{ ann.company.name }} </h3>
@ -17,6 +23,4 @@
<p> {{ ann.creationDate|date("d-m-y") }} </p>
{% endfor %}
{% endblock %}
{% endblock %}

View File

@ -1,26 +1,37 @@
{% extends 'base.html.twig' %}
{% block title %}Degree{% endblock %}
{% block title %}Degrees{% endblock %}
{% block body %}
<h1>Degree</h1>
<h1>List of Degrees</h1>
<table class="table">
<thead>
<tr>
<th>Id</th>
<th>Label</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for degree in degrees %}
<tr>
<th>Id</th>
<td>{{ degree.id }}</td>
</tr>
<tr>
<th>Label</th>
<td>{{ degree.label }}</td>
<td>
<a href="{{ path('app_degree_show', {'id': degree.id}) }}" class="btn btn-info">View</a>
<a href="{{ path('app_degree_edit', {'id': degree.id}) }}" class="btn btn-warning">Edit</a>
<!-- Form for deleting a degree -->
<form method="post" action="{{ path('app_degree_delete', {'id': degree.id}) }}" style="display:inline;">
<input type="hidden" name="_method" value="DELETE">
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ degree.id) }}">
<button class="btn btn-danger" type="submit">Delete</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<a href="{{ path('app_degree_index') }}">back to list</a>
<a href="{{ path('app_degree_edit', {'id': degree.id}) }}">edit</a>
{{ include('degree/_delete_form.html.twig') }}
<a href="{{ path('app_degree_new') }}" class="btn btn-success">Add New Degree</a>
{% endblock %}