Fixes for MultiDB payment gateways

This commit is contained in:
= 2021-09-09 21:18:04 +10:00
parent 066666f5bc
commit b3b5793703
3 changed files with 9 additions and 2 deletions

View File

@ -2,6 +2,7 @@
namespace App\Http\Requests\Gateways\Checkout3ds; namespace App\Http\Requests\Gateways\Checkout3ds;
use App\Libraries\MultiDB;
use App\Models\Client; use App\Models\Client;
use App\Models\Company; use App\Models\Company;
use App\Models\CompanyGateway; use App\Models\CompanyGateway;
@ -37,6 +38,7 @@ class Checkout3dsRequest extends FormRequest
public function getCompany() public function getCompany()
{ {
MultiDB::findAndSetDbByCompanyKey($this->company_key);
return Company::where('company_key', $this->company_key)->first(); return Company::where('company_key', $this->company_key)->first();
} }

View File

@ -640,7 +640,8 @@ class Import implements ShouldQueue
$client->updated_at = Carbon::parse($modified['updated_at']); $client->updated_at = Carbon::parse($modified['updated_at']);
$client->save(['timestamps' => false]); $client->save(['timestamps' => false]);
$client->fresh();
$client->contacts()->forceDelete(); $client->contacts()->forceDelete();
if (array_key_exists('contacts', $resource)) { // need to remove after importing new migration.json if (array_key_exists('contacts', $resource)) { // need to remove after importing new migration.json
@ -650,7 +651,7 @@ class Import implements ShouldQueue
$modified_contacts[$key]['company_id'] = $this->company->id; $modified_contacts[$key]['company_id'] = $this->company->id;
$modified_contacts[$key]['user_id'] = $this->processUserId($resource); $modified_contacts[$key]['user_id'] = $this->processUserId($resource);
$modified_contacts[$key]['client_id'] = $client->id; $modified_contacts[$key]['client_id'] = $client->id;
$modified_contacts[$key]['password'] = 'mysuperpassword'; // @todo, and clean up the code.. $modified_contacts[$key]['password'] = Str::random(8);
unset($modified_contacts[$key]['id']); unset($modified_contacts[$key]['id']);
} }
@ -685,6 +686,8 @@ class Import implements ShouldQueue
'old' => $resource['id'], 'old' => $resource['id'],
'new' => $client->id, 'new' => $client->id,
]; ];
$client = null;
} }
Client::reguard(); Client::reguard();

View File

@ -88,5 +88,7 @@ class ClientContactRepository extends BaseRepository
$new_contact->email = ' '; $new_contact->email = ' ';
$new_contact->save(); $new_contact->save();
} }
$client = null;
} }
} }