src/Controller/HomeController.php line 28

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Request;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\HttpFoundation\Session\Session;
  7. use Symfony\Component\HttpFoundation\Cookie;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. use Doctrine\DBAL\Connection;
  10. use Symfony\Component\HttpFoundation\JsonResponse;
  11. use Symfony\Component\HttpFoundation\FileBag;
  12. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  13. class HomeController extends AbstractController
  14. {
  15.     
  16.       private $connection;
  17.     public function __construct(Connection $connection)
  18.     {
  19.         $this->connection $connection;
  20.     }
  21.     #[Route('/'name'app_home')]
  22.     public function index(AuthenticationUtils $authenticationUtils): Response
  23.     {
  24.         $error $authenticationUtils->getLastAuthenticationError();
  25.         $connection $this->connection;
  26.         $sql "SELECT master_state_id, state_name
  27.         FROM master_state where status='1'
  28.         ORDER BY state_name";
  29.         $states $this->connection
  30.     ->executeQuery($sql)
  31.     ->fetchAllAssociative();
  32. $sql1 "SELECT master_country_id, country_name
  33.         FROM master_country where statu_s='active'
  34.         ORDER BY country_name";
  35.         $countries $this->connection
  36.     ->executeQuery($sql1)
  37.     ->fetchAllAssociative();
  38.         return $this->render('home/index.html.twig', [
  39.             'error' => $error,
  40.             'states'=>$states,
  41.             'countries'=>$countries
  42.         ]);
  43.     }
  44. }