From 12798e00be84167e8823532d72b28916b8fae9f6 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Tue, 27 Apr 2021 04:14:48 +0000 Subject: [PATCH] Add payment methods to hub entity and form. #554 --- src/Controller/HubController.php | 3 +++ src/Entity/Hub.php | 30 ++++++++++++++++++++++++++++++ templates/hub/form.html.twig | 16 ++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/src/Controller/HubController.php b/src/Controller/HubController.php index 864a6261..d7e10c4c 100644 --- a/src/Controller/HubController.php +++ b/src/Controller/HubController.php @@ -22,6 +22,7 @@ use App\Service\RisingTideGateway; use App\Service\HubSelector; use App\Ramcar\HubCriteria; +use App\Ramcar\ModeOfPayment; class HubController extends Controller { @@ -131,6 +132,7 @@ class HubController extends Controller $params = []; $params['obj'] = new Hub(); $params['mode'] = 'create'; + $params['payment_methods'] = ModeOfPayment::getCollection(); // response return $this->render('hub/form.html.twig', $params); @@ -238,6 +240,7 @@ class HubController extends Controller $params = []; $params['obj'] = $obj; $params['mode'] = 'update'; + $params['payment_methods'] = ModeOfPayment::getCollection(); // response return $this->render('hub/form.html.twig', $params); diff --git a/src/Entity/Hub.php b/src/Entity/Hub.php index ec4aff75..b40bc395 100644 --- a/src/Entity/Hub.php +++ b/src/Entity/Hub.php @@ -74,6 +74,12 @@ class Hub */ protected $notif_number; + // payment methods + /** + * @ORM\Column(type="array", nullable=true) + */ + protected $payment_methods; + public function __construct() { $this->time_open = new DateTime(); @@ -83,6 +89,7 @@ class Hub $this->status_open = true; $this->flag_hub_view = false; $this->notif_number = ''; + $this->payment_methods = new ArrayCollection(); } public function getRiders() @@ -203,4 +210,27 @@ class Hub return $this->notif_number; } + public function getPaymentMethods() + { + return $this->payment_methods; + } + + public function setPaymentMethods(array $payment_methods) + { + $this->payment_methods = new ArrayCollection(); + + foreach ($payment_methods as $payment_method) + { + $this->payment_methods->add($payment_method); + } + + return $this; + } + + public function clearPaymentMethods() + { + $this->payment_methods = new ArrayCollection(); + return $this; + } + } diff --git a/templates/hub/form.html.twig b/templates/hub/form.html.twig index ea300ab6..b0e14455 100644 --- a/templates/hub/form.html.twig +++ b/templates/hub/form.html.twig @@ -154,6 +154,22 @@ +
+
+ +
+ {% for payment_method in payment_methods %} + + {% endfor %} +
+ + Check all payment methods that apply +
+