From fa0c3f27e71fb6640992f8c4faeacb577fce32cb Mon Sep 17 00:00:00 2001 From: Kendall Arneaud Date: Sat, 27 Jul 2024 12:18:28 -0400 Subject: [PATCH] Update 2024_06_11_231143_add_rotessa_gateway.php Reefactored code as per request https://github.com/invoiceninja/invoiceninja/pull/9704/files/2ea54b0042b247ffdb054f7f707544a2b145ed23#r1693681342 Signed-off-by: Kendall Arneaud --- .../2024_06_11_231143_add_rotessa_gateway.php | 42 +++++++------------ 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/database/migrations/2024_06_11_231143_add_rotessa_gateway.php b/database/migrations/2024_06_11_231143_add_rotessa_gateway.php index eaade6bb4357..cb18062b40e0 100644 --- a/database/migrations/2024_06_11_231143_add_rotessa_gateway.php +++ b/database/migrations/2024_06_11_231143_add_rotessa_gateway.php @@ -15,35 +15,23 @@ return new class extends Migration public function up(): void { Model::unguard(); - \DB::statement('SET FOREIGN_KEY_CHECKS=0;'); - $record = Gateway::where('name', '=', 'Rotessa')->first(); - $count = (int) Gateway::count(); - - $configuration = new \stdClass; - $configuration->api_key = ''; - $configuration->test_mode = true; - - if (!$record) { - $gateway = new Gateway; - } else { - $gateway = $record; + if(!Gateway::find(63)) { + $configuration = new \stdClass; + $configuration->api_key = ''; + $configuration->test_mode = true; + + $gateway->id = 63; + $gateway->name = 'Rotessa'; + $gateway->key = '91be24c7b792230bced33e930ac61676'; + $gateway->provider = 'Rotessa'; + $gateway->is_offsite = true; + $gateway->fields = \json_encode($configuration); + $gateway->visible = 1; + $gateway->site_url = "https://rotessa.com"; + $gateway->default_gateway_type_id = 2; + $gateway->save(); } - - $gateway->id = 4002; - $gateway->name = 'Rotessa'; - $gateway->key = Str::lower(Str::random(32)); - $gateway->provider = 'Rotessa'; - $gateway->is_offsite = true; - $gateway->fields = \json_encode($configuration); - $gateway->visible = 1; - $gateway->site_url = "https://rotessa.com"; - $gateway->default_gateway_type_id = 2; - $gateway->save(); - - Gateway::query()->where('name','=', 'Rotessa')->update(['visible' => 1]); - - \DB::statement('SET FOREIGN_KEY_CHECKS=1;'); } /**