src/Controller/dashboard/DashboardController.php line 14

  1. <?php
  2. namespace App\Controller\dashboard;
  3. use App\Controller\BaseController;
  4. use Symfony\Component\HttpFoundation\RedirectResponse;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. class DashboardController extends BaseController
  9. {
  10.     #[Route("/"name"app_homepage")]
  11.     public function indexAction(Request $request): Response|RedirectResponse
  12.     {
  13.         if (empty($this->getUser())) {
  14.             return new RedirectResponse($this->generateUrl('login'));
  15.         }
  16.         $this->setCurrentRouteActive($request'app_homepage');
  17.         $response $this->client()->get('/api/dashboard');
  18.         $data json_decode($response->getBody()->getContents(), true);
  19.         $clients array_map(function($item) {
  20.             return [
  21.                 "Date" => $item["StartedDate"],
  22.                 "Name" => $item["CustomerName"],
  23.                 "Description" => $item["Description"],
  24.                 "JobStatus" => $item["JobStatus"]
  25.             ];
  26.         }, $data['waitingListTable']);
  27.         return $this->render('dashboard/dashboard.html.twig', [
  28.             'dashboardData' => $data,
  29.             'clientsData' => json_encode($clients)
  30.         ]);
  31.     }
  32. }