src/Controller/UserController.php line 23

  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\User;
  4. use App\Form\User1Type;
  5. use App\Repository\UserRepository;
  6. use Doctrine\ORM\EntityManagerInterface;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use Symfony\Component\HttpFoundation\Request;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\Routing\Annotation\Route;
  11. use Knp\Component\Pager\PaginatorInterface;
  12. #[Route('/user')]
  13. class UserController extends AbstractController
  14. {
  15. #[Route('/privacy'name'privacy')]
  16. public function privacy(EntityManagerInterface $entityManager): Response
  17. {
  18.     $html = <<<HTML
  19. <!DOCTYPE html>
  20. <html lang="en">
  21. <head>
  22.     <meta charset="UTF-8">
  23.     <title>Privacy Policy - LVB</title>
  24.     <style>
  25.         body { font-family: Arial, sans-serif; padding: 20px; line-height: 1.6; max-width: 800px; margin: auto; }
  26.         h1, h2 { color: #2c3e50; }
  27.         ul { margin-top: 0; }
  28.         .section { margin-bottom: 30px; }
  29.     </style>
  30. </head>
  31. <body>
  32.     <h1>Privacy Policy</h1>
  33.     <p><strong>Last updated:</strong> April 4, 2025</p>
  34.     <div class="section">
  35.         <h2>Welcome to LVB</h2>
  36.         <p>LVB is your trusted platform for connecting with skilled professionals offering services such as:</p>
  37.         <ul>
  38.             <li>Home Services</li>
  39.             <li>Beauty and Wellness Treatments</li>
  40.             <li>Personal Training and Coaching</li>
  41.         </ul>
  42.     </div>
  43.     <div class="section">
  44.         <h2>Your Privacy Matters</h2>
  45.         <p>At LVB, we prioritize the privacy and security of our users. We do not collect or store any unnecessary personal information related to your activities. The only data we handle pertains to service bookings, provider profiles, and client-provider interactions — all used solely to deliver the best experience possible.</p>
  46.     </div>
  47.  
  48.     <div class="section">
  49.         <h2>Security & Transparency</h2>
  50.         <p>We implement strict safeguards to keep your information secure, including encrypted storage and verified service providers. Our platform is designed to give you peace of mind while using our services.</p>
  51.     </div>
  52.     <div class="section">
  53.         <h2>Your Rights</h2>
  54.         <ul>
  55.             <li>Access and modify your personal data</li>
  56.             <li>Request account deletion</li>
  57.             <li>Contact support for any privacy concerns</li>
  58.         </ul>
  59.     </div>
  60.     <div class="section">
  61.         <h2>Contact Us</h2>
  62.         <p>If you have any questions about this Privacy Policy, please contact us:</p>
  63.         <p>Email: <a href="mailto:support@lvb.app">support@lvb.app</a><br>
  64.           </p>
  65.     </div>
  66.     <p>Thank you for using LVB. We are committed to maintaining your trust.</p>
  67. </body>
  68. </html>
  69. HTML;
  70.     return new Response($html);
  71. }
  72. #[Route('/accepted'name'app_users_accepted')]
  73.     public function showAcceptedUsers(EntityManagerInterface $entityManager)
  74.     {
  75.         // Fetch users with status 1 (Accepted)
  76.         $users $entityManager->getRepository(User::class)->findBy(['status' => 1]);
  77.         return $this->render('user/accepted_users.html.twig', [
  78.             'users' => $users,
  79.         ]);
  80.     }
  81.     #[Route('/rejected'name'app_users_rejected')]
  82.     public function showRejectedUsers(EntityManagerInterface $entityManager)
  83.     {
  84.         // Fetch users with status 2 (Rejected)
  85.         $users $entityManager->getRepository(User::class)->findBy(['status' => 2]);
  86.         return $this->render('user/rejected_users.html.twig', [
  87.             'users' => $users,
  88.         ]);
  89.     }
  90.  #[Route('/pending'name'app_users_pending')]
  91.     public function showPendingUsers(EntityManagerInterface $entityManager)
  92.     {
  93.         // Fetch users with status 0
  94.         $users $entityManager->getRepository(User::class)->findBy(['status' => 0]);
  95.         return $this->render('user/pending_users.html.twig', [
  96.             'users' => $users,
  97.         ]);
  98.     }
  99.     #[Route('/update-status/{id}/{status}'name'app_users_update_status')]
  100.     public function updateUserStatus($id$statusEntityManagerInterface $entityManagerRequest $request)
  101.     {
  102.         // Fetch the user by ID
  103.         $user $entityManager->getRepository(User::class)->find($id);
  104.         if (!$user) {
  105.             $this->addFlash('error''User not found');
  106.             return $this->redirectToRoute('app_users_pending');
  107.         }
  108.         // Update the status
  109.         $user->setStatus($status);
  110.         $entityManager->flush();
  111.         $this->addFlash('success''User status updated successfully');
  112.         return $this->redirectToRoute('app_users_pending');
  113.     }
  114.     #[Route('/'name'app_user_index'methods: ['GET'])]
  115.     public function index(UserRepository $userRepository): Response
  116.     {
  117.         return $this->render('user/index.html.twig', [
  118.             'users' => $userRepository->findAll(),
  119.         ]);
  120.     }
  121.     #[Route('/new'name'app_user_new'methods: ['GET''POST'])]
  122.     public function new(Request $requestEntityManagerInterface $entityManager): Response
  123.     {
  124.         $user = new User();
  125.         $form $this->createForm(User1Type::class, $user);
  126.         $form->handleRequest($request);
  127.         if ($form->isSubmitted() && $form->isValid()) {
  128.             $entityManager->persist($user);
  129.             $entityManager->flush();
  130.             return $this->redirectToRoute('app_user_index', [], Response::HTTP_SEE_OTHER);
  131.         }
  132.         return $this->render('user/new.html.twig', [
  133.             'user' => $user,
  134.             'form' => $form,
  135.         ]);
  136.     }
  137.     #[Route('/{id}'name'app_user_show'methods: ['GET'])]
  138.     public function show(User $user): Response
  139.     {
  140.         return $this->render('user/show.html.twig', [
  141.             'user' => $user,
  142.         ]);
  143.     }
  144.     #[Route('/{id}/edit'name'app_user_edit'methods: ['GET''POST'])]
  145.     public function edit(Request $requestUser $userEntityManagerInterface $entityManager): Response
  146.     {
  147.         $form $this->createForm(User1Type::class, $user);
  148.         $form->handleRequest($request);
  149.         if ($form->isSubmitted() && $form->isValid()) {
  150.             $entityManager->flush();
  151.             return $this->redirectToRoute('app_user_index', [], Response::HTTP_SEE_OTHER);
  152.         }
  153.         return $this->render('user/edit.html.twig', [
  154.             'user' => $user,
  155.             'form' => $form,
  156.         ]);
  157.     }
  158.     #[Route('/{id}'name'app_user_delete'methods: ['POST'])]
  159.     public function delete(Request $requestUser $userEntityManagerInterface $entityManager): Response
  160.     {
  161.         if ($this->isCsrfTokenValid('delete'.$user->getId(), $request->request->get('_token'))) {
  162.             $entityManager->remove($user);
  163.             $entityManager->flush();
  164.         }
  165.         return $this->redirectToRoute('app_user_index', [], Response::HTTP_SEE_OTHER);
  166.     }
  167. }