src/Controller/Services/BillPaymentController.php line 42

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Services;
  3. use App\Entity\Deals;
  4. use App\Form\Services\BillType;
  5. use App\Entity\Payments\Save\Service;
  6. use Doctrine\ORM\EntityManagerInterface;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\HttpFoundation\JsonResponse;
  10. use Symfony\Component\Routing\Annotation\Route;
  11. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  12. class BillPaymentController extends AbstractController
  13. {
  14.     protected $em;
  15.     public function __construct(EntityManagerInterface $entityManager)
  16.     {
  17.         $this->em $entityManager;
  18.     }
  19.     /**
  20.      * @Route("/send/paybill", name="app_pay_bill")
  21.      */
  22.     public function getPaymentBill(Request $request): Response
  23.     {
  24.         $tabResult['statut'] = FALSE;
  25.         $values $request->request->all();
  26.         $idBill $values['id_bill'];
  27.         $orderNumber $values['order_number'];
  28.         $result $this->em->getRepository(Service::class)->findOneBy(["id_bill" => $idBill"order_number" => $orderNumber]);
  29.         if(!empty($result)){
  30.             $tabResult['statut'] = TRUE;
  31.             $tabResult['amount'] = $result->getAmount();
  32.         }
  33.         return new JsonResponse($tabResult);
  34.     }
  35.     public function index(): Response
  36.     {
  37.         $deals $this->em->getRepository(Deals::class)->findBy(["statut"=> 1]);
  38.         $service = new Service;
  39.         $form $this->createForm(BillType::class, $service, [
  40.             'action'    =>      $this->generateUrl('service-payment-capture'),
  41.             'method'    =>      'POST'
  42.         ]);
  43.         return $this->render('services/bill_payment/index.html.twig', [
  44.             "form"      => $form->createView(),
  45.             "deals"     => $deals
  46.         ]);
  47.     }
  48. }