add view profile, and create edit profile route
This commit is contained in:
36
src/Controller/ProfileController.php
Normal file
36
src/Controller/ProfileController.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\Form\RegistrationFormType;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
use App\Repository\ParticipantRepository;
|
||||||
|
|
||||||
|
class ProfileController extends AbstractController
|
||||||
|
{
|
||||||
|
#[Route('/profile/{uuid}', name: 'profile_view', methods: ['GET'])]
|
||||||
|
public function viewProfile(string $uuid, ParticipantRepository $participantRepository): Response
|
||||||
|
{
|
||||||
|
$currentProfile = $participantRepository->findOneBy(['idParticipant' => $uuid]);
|
||||||
|
return $this->render('profile/view.html.twig', [
|
||||||
|
'profile' => $currentProfile,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route('/profile/edit/{uuid}', name: 'profile_edit', methods: ['GET', 'POST'])]
|
||||||
|
public function editProfile(string $uuid, ParticipantRepository $participantRepository, Request $request): Response
|
||||||
|
{
|
||||||
|
$currentProfile = $participantRepository->findOneBy(['idParticipant' => $uuid]);
|
||||||
|
$form = $this->createForm(RegistrationFormType::class, $currentProfile);
|
||||||
|
$form->handleRequest($request);
|
||||||
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return $this->render('profile/view.html.twig', [
|
||||||
|
'profile' => $currentProfile,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,10 +23,10 @@
|
|||||||
<img alt="burger-menu" src="{{ asset('img/burger-menu.svg') }}">
|
<img alt="burger-menu" src="{{ asset('img/burger-menu.svg') }}">
|
||||||
</button>
|
</button>
|
||||||
<ul id="navbar" class="hidden absolute top-12 right-0 w-48 bg-white shadow-md p-4 flex-col space-y-4">
|
<ul id="navbar" class="hidden absolute top-12 right-0 w-48 bg-white shadow-md p-4 flex-col space-y-4">
|
||||||
<li><a href="/" class="text-gray-700 font-bold hover:text-blue-500">Accueil</a></li>
|
<li><a href="{{ path('home') }}" class="text-gray-700 font-bold hover:text-blue-500">Accueil</a></li>
|
||||||
<li><a href="/" class="text-gray-700 font-bold hover:text-blue-500">Sortie</a></li>
|
<li><a href="{{ path('profile_view', {'uuid': app.user.idParticipant}) }}" class="text-gray-700 font-bold hover:text-blue-500">Mon profile</a></li>
|
||||||
<li><a href="/" class="text-gray-700 font-bold hover:text-blue-500">ToDo</a></li>
|
<li><a href="{{ path('home') }}" class="text-gray-700 font-bold hover:text-blue-500">ToDo</a></li>
|
||||||
<li><a href="/" class="text-gray-700 font-bold hover:text-blue-500">À propos</a></li>
|
<li><a href="{{ path('home') }}" class="text-gray-700 font-bold hover:text-blue-500">À propos</a></li>
|
||||||
{% if app.user %}
|
{% if app.user %}
|
||||||
<li><a href="{{ path('app_logout') }}" class="text-gray-700 font-bold hover:text-blue-500">Se déconnecter</a></li>
|
<li><a href="{{ path('app_logout') }}" class="text-gray-700 font-bold hover:text-blue-500">Se déconnecter</a></li>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|||||||
20
templates/profile/index.html.twig
Normal file
20
templates/profile/index.html.twig
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
<title>Hello ProfileController!</title>
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<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; }
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<div class="example-wrapper">
|
||||||
|
<h1>Hello {{ controller_name }}! ✅</h1>
|
||||||
|
|
||||||
|
This friendly message is coming from:
|
||||||
|
<ul>
|
||||||
|
<li>Your controller at <code>C:/Users/oparpaillon2023/Desktop/Projet/sortir/src/Controller/ProfileController.php</code></li>
|
||||||
|
<li>Your template at <code>C:/Users/oparpaillon2023/Desktop/Projet/sortir/templates/profile/index.html.twig</code></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
36
templates/profile/view.html.twig
Normal file
36
templates/profile/view.html.twig
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
{% extends 'main/base.html.twig' %}
|
||||||
|
{% block head %}
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
{% block stylesheets %}
|
||||||
|
{{ encore_entry_link_tags('app') }}
|
||||||
|
{% endblock %}
|
||||||
|
</head>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="relative max-w-md mx-auto md:max-w-2xl py-48 min-w-0 break-words w-full">
|
||||||
|
<div class="px-6 bg-white shadow-lg rounded-lg py-2">
|
||||||
|
<div class="flex flex-wrap justify-center">
|
||||||
|
<div class="w-full flex justify-center">
|
||||||
|
{# <div class="relative">#}
|
||||||
|
{# <img src="{{ profile.imageFilename ? asset('upload/image/profile/' ~ profile.imageFilename) : "" }}" class="shadow-xl rounded-full align-middle border-none absolute -m-16 -ml-20 lg:-ml-16 max-w-[150px]"/>#}
|
||||||
|
{# </div>#}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="text-center mt-2">
|
||||||
|
<h3 class="text-2xl text-slate-700 font-bold leading-normal mb-1">{{ profile.prenom }} {{ profile.nom }}</h3>
|
||||||
|
<div class="text-xs mt-0 mb-2 text-slate-400 font-bold uppercase">
|
||||||
|
<i class="fas fa-map-marker-alt mr-2 text-slate-400 opacity-75"></i>{{ profile.telephone }} - {{ profile.email }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mt-6 py-6 border-t border-slate-200 text-center">
|
||||||
|
<div class="flex flex-wrap justify-center">
|
||||||
|
<div class="w-full px-4">
|
||||||
|
<a href="{{ path('profile_edit', {'uuid': app.user.idParticipant}) }}" class="text-slate-700 hover:text-slate-400">Modifier</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user