src/Controller/proController.php line 78

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Contracts\HttpClient\HttpClientInterface;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use App\Service\StripeService;
  9. class proController extends AbstractController
  10. {
  11.     const PARRAIN_CODE_IMPORTED '123I321';
  12.     private $client;
  13.     public function __construct(HttpClientInterface $client)
  14.     {
  15.         $this->client $client;
  16.     }
  17.     
  18.     /**
  19.      * @Route("/pro")
  20.      */
  21.     public function renderAccueilProPage()
  22.     {
  23.         
  24.         $response $this->client->request(
  25.             'GET',
  26.             "{$_ENV['BASE_API']}articles/pro?limit=6"
  27.         );
  28.         $content $response->toArray()["articles"];
  29.         return $this->render('/pro/accueil.html.twig', array(
  30.             "articles" => $content,
  31.         ));
  32.         
  33.     }
  34.     
  35.     /**
  36.      * @Route("/pro/les-avantages")
  37.      */
  38.     public function renderAvantagesProPage()
  39.     {
  40.         return $this->render('/pro/lesAvantages.html.twig', array(
  41.         ));
  42.         
  43.     }
  44.     /**
  45.      * @Route("/pro/qui-sommes-nous")
  46.      */
  47.     public function renderQSNProPage()
  48.     {
  49.         return $this->render('/pro/quiSommesNous.html.twig', array(
  50.         ));
  51.         
  52.     }
  53.      /**
  54.      * @Route("/pro/nos-tarifs")
  55.      */
  56.     public function renderNosTarifsProPage()
  57.     {
  58.         return $this->render('/pro/nos-tarifs.html.twig', array(
  59.         ));
  60.         
  61.     }
  62.    
  63.     /**
  64.      * @Route("/pro/inscription",methods={"GET", "POST"})
  65.      */
  66.     public function renderInscriptionProPage(Request $request)
  67.     {
  68.      //  dd(strtotime(date('H:i:s Y-m-d', strtotime('+1 month'))));
  69.         $response $this->client->request(
  70.             'GET',
  71.             "{$_ENV['BASE_API']}prestations"
  72.         );
  73.         $prestations $response->toArray()["prestations"];
  74.         $response $this->client->request(
  75.             'GET',
  76.             "{$_ENV['BASE_API']}mutuelles"
  77.         );
  78.         $mutuelles $response->toArray()["mutuelles"];
  79.         $response $this->client->request(
  80.             'GET',
  81.             "{$_ENV['BASE_API']}specialites"
  82.         );
  83.         $specialites $response->toArray()["specialites"];
  84.         $response $this->client->request(
  85.             'GET',
  86.             "{$_ENV['BASE_API']}diplomes"
  87.         );
  88.         $diplomes $response->toArray()["diplomes"];
  89.         
  90.         $response $this->client->request(
  91.             'GET',
  92.             "{$_ENV['BASE_API']}stations/city"
  93.         );
  94.         $stations $response->toArray()["stations"];
  95.         // Initialize the variable
  96.         $centreImported null;
  97.         $parrain null;
  98.         // Check if the "parrain" parameter exists in the URL and get the imported
  99.         if ($request->query->has('parrain')) {
  100.             $parrainId $request->query->get('parrain');
  101.             $id substr$parrainId,strlen(self::PARRAIN_CODE_IMPORTED));
  102.             $parrain self::PARRAIN_CODE_IMPORTED;
  103.             $response $this->client->request(
  104.                 'GET',
  105.                 "{$_ENV['BASE_API']}centreImported/".$id
  106.         );
  107.         $centreImported $response->toArray();
  108.         }
  109.         return $this->render('./pro/inscription.html.twig', array(
  110.             "prestations" => $prestations,
  111.             "mutuelles" => $mutuelles,
  112.             "specialites" => $specialites,
  113.             "diplomes" => $diplomes,
  114.             'centreImported' => $centreImported,
  115.             'parrain' => $parrain,
  116.             "stations" => $stations,
  117.         ));
  118.         
  119.     }
  120.       /**
  121.      * @Route("/pro/second",methods={"GET", "POST"})
  122.      */
  123.     public function rendersecondInscriptionProPage(StripeService $stripeService)
  124.     {
  125.        
  126.         $response $this->client->request(
  127.             'GET',
  128.             "{$_ENV['BASE_API']}prestations"
  129.         );
  130.         $prestations $response->toArray()["prestations"];
  131.         $response $this->client->request(
  132.             'GET',
  133.             "{$_ENV['BASE_API']}mutuelles"
  134.         );
  135.         $mutuelles $response->toArray()["mutuelles"];
  136.         $response $this->client->request(
  137.             'GET',
  138.             "{$_ENV['BASE_API']}specialites"
  139.         );
  140.         $specialites $response->toArray()["specialites"];
  141.         $response $this->client->request(
  142.             'GET',
  143.             "{$_ENV['BASE_API']}diplomes"
  144.         );
  145.         $diplomes $response->toArray()["diplomes"];
  146.         
  147.         $response $this->client->request(
  148.             'GET',
  149.             "{$_ENV['BASE_API']}stations/city"
  150.         );
  151.         $stations $response->toArray()["stations"];
  152.         
  153.         return $this->render('./pro/secondinscri.html.twig', array(
  154.             "prestations" => $prestations,
  155.             "mutuelles" => $mutuelles,
  156.             "specialites" => $specialites,
  157.             "diplomes" => $diplomes,
  158.             "stations" => $stations,
  159.         ));
  160.         
  161.     }
  162.       /**
  163.      * @Route("/pro/intent/{intent}")
  164.      */
  165.     public function renderStripePage($intent)
  166.     {
  167.         return $this->render('/pro/stripe.html.twig', array(
  168.             'intentSecret' => $intent
  169.         ));
  170.         
  171.     }
  172.        /**
  173.      * @Route("/pro/inscription/termine",name="termination")
  174.      */
  175.     public function renderFinishedPaymentPage()
  176.     {
  177.         return $this->render('/pro/success.html.twig', array(
  178.             //'intentSecret' => $intent
  179.         ));
  180.         
  181.     }
  182.        /**
  183.      * @Route("/pro/addAudio")
  184.      */
  185.     public function renderAddAudioProPage(Request $request)
  186.     {
  187.         $data json_decode($request->getContent(), true);
  188.         $response $this->client->request(
  189.             'GET',
  190.             "{$_ENV['BASE_API']}prestations"
  191.         );
  192.         $prestations $response->toArray()["prestations"];
  193.         $response $this->client->request(
  194.             'GET',
  195.             "{$_ENV['BASE_API']}mutuelles"
  196.         );
  197.         $mutuelles $response->toArray()["mutuelles"];
  198.         $response $this->client->request(
  199.             'GET',
  200.             "{$_ENV['BASE_API']}specialites"
  201.         );
  202.         $specialites $response->toArray()["specialites"];
  203.         $response $this->client->request(
  204.             'GET',
  205.             "{$_ENV['BASE_API']}diplomes"
  206.         );
  207.         $diplomes $response->toArray()["diplomes"];
  208.         
  209.         $response $this->client->request(
  210.             'GET',
  211.             "{$_ENV['BASE_API']}roles"
  212.         );
  213.         $roles $response->toArray()["roles"];
  214.         return $this->render('./pro/addAudio.html.twig', array(
  215.             "nbAudio" => $data['nbAudio'],
  216.             "prestations" => $prestations,
  217.             "mutuelles" => $mutuelles,
  218.             "specialites" => $specialites,
  219.             "roles" => $roles,
  220.             "diplomes" => $diplomes,
  221.         ));
  222.         
  223.     }
  224.     
  225. }
  226. ?>