This commit is contained in:
barillote 2024-11-28 17:15:33 +01:00
parent 353884f58f
commit 5934dfcdf5
7 changed files with 63 additions and 70 deletions

View File

@ -50,7 +50,7 @@ security:
# switch_user: true # switch_user: true
role_hierarchy: role_hierarchy:
ROLE_ADMIN: ROLE_ADMIN ROLE_ADMIN: [ ROLE_ADMIN, ROLE_EMPLOYEE, ROLE_USER ]
ROLE_EMPLOYEE: ROLE_EMPLOYEE ROLE_EMPLOYEE: ROLE_EMPLOYEE
ROLE_USER: ROLE_USER ROLE_USER: ROLE_USER
# Easy way to control access for large sections of your site # Easy way to control access for large sections of your site

View File

@ -2,6 +2,7 @@
namespace App\Controller; namespace App\Controller;
use App\Entity\UserApp;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Routing\Attribute\Route;
@ -11,7 +12,9 @@ class IndexController extends AbstractController
#[Route('/index', name: 'app_index')] #[Route('/index', name: 'app_index')]
public function index(): Response public function index(): Response
{ {
return $this->render('index/index.html.twig', []); return $this->render('index/index.html.twig', [
'id' => $this->getUser()->getId(),
]);
} }
#[Route('/test', name: 'app_test')] #[Route('/test', name: 'app_test')]

View File

@ -11,7 +11,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Routing\Attribute\Route;
#[Route('/user/app')] #[Route('/user')]
final class UserAppController extends AbstractController final class UserAppController extends AbstractController
{ {
#[Route(name: 'app_user_app_index', methods: ['GET'])] #[Route(name: 'app_user_app_index', methods: ['GET'])]
@ -22,25 +22,25 @@ final class UserAppController extends AbstractController
]); ]);
} }
#[Route('/new', name: 'app_user_app_new', methods: ['GET', 'POST'])] // #[Route('/new', name: 'app_user_app_new', methods: ['GET', 'POST'])]
public function new(Request $request, EntityManagerInterface $entityManager): Response // public function new(Request $request, EntityManagerInterface $entityManager): Response
{ // {
$userApp = new UserApp(); // $userApp = new UserApp();
$form = $this->createForm(UserAppType::class, $userApp); // $form = $this->createForm(UserAppType::class, $userApp);
$form->handleRequest($request); // $form->handleRequest($request);
//
if ($form->isSubmitted() && $form->isValid()) { // if ($form->isSubmitted() && $form->isValid()) {
$entityManager->persist($userApp); // $entityManager->persist($userApp);
$entityManager->flush(); // $entityManager->flush();
//
return $this->redirectToRoute('app_user_app_index', [], Response::HTTP_SEE_OTHER); // return $this->redirectToRoute('app_user_app_index', [], Response::HTTP_SEE_OTHER);
} // }
//
return $this->render('user_app/new.html.twig', [ // return $this->render('user_app/new.html.twig', [
'user_app' => $userApp, // 'user_app' => $userApp,
'form' => $form, // 'form' => $form,
]); // ]);
} // }
#[Route('/{id}', name: 'app_user_app_show', methods: ['GET'])] #[Route('/{id}', name: 'app_user_app_show', methods: ['GET'])]
public function show(UserApp $userApp): Response public function show(UserApp $userApp): Response

View File

@ -31,11 +31,13 @@
<a class="hover:text-teal-400" href="{{ path('app_index') }}">À propos de nous</a> <a class="hover:text-teal-400" href="{{ path('app_index') }}">À propos de nous</a>
<a class="hover:text-teal-400" href="{{ path('app_index') }}">Nous contacter</a> <a class="hover:text-teal-400" href="{{ path('app_index') }}">Nous contacter</a>
</nav> </nav>
{% if app.user %}
<div> <div>
<a class="bg-teal-500 hover:bg-teal-600 text-white py-2 px-4 rounded-full" href="{{ path('app_index') }}"> <a class="bg-teal-500 hover:bg-teal-600 text-white py-2 px-4 rounded-full" href="{{ path('app_user_app_show', { id: app.user.id }) }}">
Profil Profil
</a> </a>
</div> </div>
{% endif %}
</div> </div>
</header> </header>

View File

@ -8,9 +8,9 @@
<h2 class="text-2xl font-bold text-center mb-2">Connexion</h2> <h2 class="text-2xl font-bold text-center mb-2">Connexion</h2>
<p class="text-center text-gray-600 mb-6"> <p class="text-center text-gray-600 mb-6">
Pas encore inscrit ? Inscrivez vous !! <br> Pas encore inscrit ? Inscrivez vous !! <br>
<a href="{{ path('app_register_intern') }}" class="text-teal-600 hover:underline">En tant que Stagiaire</a> <a href="{{ path('app_register_intern') }}" class="text-teal-600 hover:underline">En tant que stagiaire</a>
<br> <br>
<a href="{{ path('app_register_employee') }}" class="text-teal-600 hover:underline">En tant qu'Entreprise</a> <a href="{{ path('app_register_employee') }}" class="text-teal-600 hover:underline">En tant qu'entreprise</a>
</p> </p>
<form method="post"> <form method="post">

View File

@ -1,4 +1,4 @@
<form method="post" action="{{ path('app_user_app_delete', {'id': user_app.id}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');"> <form method="post" action="{{ path('app_user_app_delete', {'id': user_app.id}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');">
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ user_app.id) }}"> <input type="hidden" name="_token" value="{{ csrf_token('delete' ~ user_app.id) }}">
<button class="btn">Delete</button> <button class="bg-red-600 hover:bg-teal-600 text-white py-2 px-4 rounded-full">Supprimer</button>
</form> </form>

View File

@ -3,52 +3,40 @@
{% block title %}UserApp{% endblock %} {% block title %}UserApp{% endblock %}
{% block body %} {% block body %}
<h1>UserApp</h1> <div class="gap-y-5">
<div class="flex gap-x-5">
<p class="font-bold">Nom d'utilisateur : </p>
<p>{{ user_app.nickname }}</p>
</div>
<div class="flex gap-x-5">
<p class="font-bold">Rôles : </p>
<p>{{ user_app.roles ? user_app.roles|json_encode : '' }}</p>
</div>
<div class="flex gap-x-5">
<p class="font-bold">Prénom : </p>
<p>{{ user_app.firstName }}</p>
</div>
<div class="flex gap-x-5">
<p class="font-bold">Nom : </p>
<p>{{ user_app.lastName }}</p>
</div>
<div class="flex gap-x-5">
<p class="font-bold">Téléphone : </p>
<p>{{ user_app.tel }}</p>
</div>
<div class="flex gap-x-5">
<p class="font-bold">Addresse : </p>
<p>{{ user_app.address }}</p>
</div>
<div class="flex gap-x-5">
<p class="font-bold">Mail : </p>
<p>{{ user_app.mail }}</p>
</div>
<table class="table"> <a href="{{ path('app_user_app_edit', {'id': user_app.id}) }}">Modifier</a>
<tbody>
<tr>
<th>Id</th>
<td>{{ user_app.id }}</td>
</tr>
<tr>
<th>Nickname</th>
<td>{{ user_app.nickname }}</td>
</tr>
<tr>
<th>Roles</th>
<td>{{ user_app.roles ? user_app.roles|json_encode : '' }}</td>
</tr>
<tr>
<th>Password</th>
<td>{{ user_app.password }}</td>
</tr>
<tr>
<th>FirstName</th>
<td>{{ user_app.firstName }}</td>
</tr>
<tr>
<th>LastName</th>
<td>{{ user_app.lastName }}</td>
</tr>
<tr>
<th>Tel</th>
<td>{{ user_app.tel }}</td>
</tr>
<tr>
<th>Address</th>
<td>{{ user_app.address }}</td>
</tr>
<tr>
<th>Mail</th>
<td>{{ user_app.mail }}</td>
</tr>
</tbody>
</table>
<a href="{{ path('app_user_app_index') }}">back to list</a> {{ include('user_app/_delete_form.html.twig') }}
</div>
<a href="{{ path('app_user_app_edit', {'id': user_app.id}) }}">edit</a>
{{ include('user_app/_delete_form.html.twig') }}
{% endblock %} {% endblock %}