From ea6905f4a0ae95e42cf1dfdbaaf19a95bda323fe Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 20 Feb 2022 15:58:58 +1100 Subject: [PATCH] Revert Payment method getters --- app/Services/Client/PaymentMethod.php | 30 ++++++++++++--------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/app/Services/Client/PaymentMethod.php b/app/Services/Client/PaymentMethod.php index 1783dd577d10..4a18387d2215 100644 --- a/app/Services/Client/PaymentMethod.php +++ b/app/Services/Client/PaymentMethod.php @@ -70,26 +70,24 @@ class PaymentMethod $transformed_ids = $this->transformKeys(explode(',', $company_gateways)); - $this->gateways = $this->client - ->company - ->company_gateways + $this->gateways = + CompanyGateway::with('gateway') + ->where('company_id', $this->client->company_id) ->whereIn('id', $transformed_ids) ->where('is_deleted', false) ->whereNull('deleted_at') ->where('gateway_key', '!=', '54faab2ab6e3223dbe848b1686490baa') ->sortby(function ($model) use ($transformed_ids) { //company gateways are sorted in order of priority return array_search($model->id, $transformed_ids);// this closure sorts for us - }); + })->get(); } else { - $this->gateways = $this->client - ->company - ->company_gateways + $this->gateways = CompanyGateway::with('gateway') + ->where('company_id', $this->client->company_id) ->where('gateway_key', '!=', '54faab2ab6e3223dbe848b1686490baa') ->whereNull('deleted_at') - ->where('is_deleted', false); - + ->where('is_deleted', false)->get(); } @@ -107,25 +105,23 @@ class PaymentMethod $transformed_ids = $this->transformKeys(explode(',', $company_gateways)); - $this->gateways = $this->client - ->company - ->company_gateways + $this->gateways = CompanyGateway::with('gateway') + ->where('company_id', $this->client->company_id) ->whereIn('id', $transformed_ids) ->where('is_deleted', false) ->whereNull('deleted_at') ->where('gateway_key', '54faab2ab6e3223dbe848b1686490baa') ->sortby(function ($model) use ($transformed_ids) { //company gateways are sorted in order of priority return array_search($model->id, $transformed_ids);// this closure sorts for us - }); + })->get(); } else { - $this->gateways = $this->client - ->company - ->company_gateways + $this->gateways = CompanyGateway::with('gateway') + ->where('company_id', $this->client->company_id) ->where('gateway_key', '54faab2ab6e3223dbe848b1686490baa') ->whereNull('deleted_at') - ->where('is_deleted', false); + ->where('is_deleted', false)->get(); }