mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge pull request #5849 from turbo124/v5-develop
Remove strict dependencies for MySQL
This commit is contained in:
commit
28fc672a26
@ -121,7 +121,7 @@ class CompanyExport implements ShouldQueue
|
|||||||
$user->account_id = $this->encodePrimaryKey($user->account_id);
|
$user->account_id = $this->encodePrimaryKey($user->account_id);
|
||||||
// $user->id = $this->encodePrimaryKey($user->id);
|
// $user->id = $this->encodePrimaryKey($user->id);
|
||||||
|
|
||||||
return $user;
|
return $user->makeVisible(['id']);
|
||||||
|
|
||||||
})->all();
|
})->all();
|
||||||
|
|
||||||
@ -205,7 +205,7 @@ class CompanyExport implements ShouldQueue
|
|||||||
$credit = $this->transformBasicEntities($credit);
|
$credit = $this->transformBasicEntities($credit);
|
||||||
$credit = $this->transformArrayOfKeys($credit, ['recurring_id','client_id', 'vendor_id', 'project_id', 'design_id', 'subscription_id','invoice_id']);
|
$credit = $this->transformArrayOfKeys($credit, ['recurring_id','client_id', 'vendor_id', 'project_id', 'design_id', 'subscription_id','invoice_id']);
|
||||||
|
|
||||||
return $credit;
|
return $credit->makeVisible(['id']);
|
||||||
|
|
||||||
})->all();
|
})->all();
|
||||||
|
|
||||||
@ -214,7 +214,7 @@ class CompanyExport implements ShouldQueue
|
|||||||
|
|
||||||
$credit = $this->transformArrayOfKeys($credit, ['company_id', 'user_id', 'client_contact_id', 'recurring_invoice_id']);
|
$credit = $this->transformArrayOfKeys($credit, ['company_id', 'user_id', 'client_contact_id', 'recurring_invoice_id']);
|
||||||
|
|
||||||
return $credit;
|
return $credit->makeVisible(['id']);
|
||||||
|
|
||||||
})->all();
|
})->all();
|
||||||
|
|
||||||
@ -224,7 +224,7 @@ class CompanyExport implements ShouldQueue
|
|||||||
|
|
||||||
$document = $this->transformArrayOfKeys($document, ['user_id', 'assigned_user_id', 'company_id', 'project_id', 'vendor_id']);
|
$document = $this->transformArrayOfKeys($document, ['user_id', 'assigned_user_id', 'company_id', 'project_id', 'vendor_id']);
|
||||||
|
|
||||||
return $document;
|
return $document->makeVisible(['id']);
|
||||||
|
|
||||||
})->all();
|
})->all();
|
||||||
|
|
||||||
@ -232,7 +232,7 @@ class CompanyExport implements ShouldQueue
|
|||||||
|
|
||||||
$expense_category = $this->transformArrayOfKeys($expense_category, ['user_id', 'company_id']);
|
$expense_category = $this->transformArrayOfKeys($expense_category, ['user_id', 'company_id']);
|
||||||
|
|
||||||
return $expense_category;
|
return $expense_category->makeVisible(['id']);
|
||||||
|
|
||||||
})->all();
|
})->all();
|
||||||
|
|
||||||
@ -242,7 +242,7 @@ class CompanyExport implements ShouldQueue
|
|||||||
$expense = $this->transformBasicEntities($expense);
|
$expense = $this->transformBasicEntities($expense);
|
||||||
$expense = $this->transformArrayOfKeys($expense, ['vendor_id', 'invoice_id', 'client_id', 'category_id', 'recurring_expense_id','project_id']);
|
$expense = $this->transformArrayOfKeys($expense, ['vendor_id', 'invoice_id', 'client_id', 'category_id', 'recurring_expense_id','project_id']);
|
||||||
|
|
||||||
return $expense;
|
return $expense->makeVisible(['id']);
|
||||||
|
|
||||||
})->all();
|
})->all();
|
||||||
|
|
||||||
@ -250,7 +250,7 @@ class CompanyExport implements ShouldQueue
|
|||||||
|
|
||||||
$gs = $this->transformArrayOfKeys($gs, ['user_id', 'company_id']);
|
$gs = $this->transformArrayOfKeys($gs, ['user_id', 'company_id']);
|
||||||
|
|
||||||
return $gs;
|
return $gs->makeVisible(['id']);
|
||||||
|
|
||||||
})->all();
|
})->all();
|
||||||
|
|
||||||
@ -260,7 +260,7 @@ class CompanyExport implements ShouldQueue
|
|||||||
$invoice = $this->transformBasicEntities($invoice);
|
$invoice = $this->transformBasicEntities($invoice);
|
||||||
$invoice = $this->transformArrayOfKeys($invoice, ['recurring_id','client_id', 'vendor_id', 'project_id', 'design_id', 'subscription_id']);
|
$invoice = $this->transformArrayOfKeys($invoice, ['recurring_id','client_id', 'vendor_id', 'project_id', 'design_id', 'subscription_id']);
|
||||||
|
|
||||||
return $invoice;
|
return $invoice->makeVisible(['id']);
|
||||||
|
|
||||||
})->all();
|
})->all();
|
||||||
|
|
||||||
@ -269,7 +269,7 @@ class CompanyExport implements ShouldQueue
|
|||||||
|
|
||||||
$invoice = $this->transformArrayOfKeys($invoice, ['company_id', 'user_id', 'client_contact_id', 'recurring_invoice_id']);
|
$invoice = $this->transformArrayOfKeys($invoice, ['company_id', 'user_id', 'client_contact_id', 'recurring_invoice_id']);
|
||||||
|
|
||||||
return $invoice;
|
return $invoice->makeVisible(['id']);
|
||||||
|
|
||||||
})->all();
|
})->all();
|
||||||
|
|
||||||
@ -312,7 +312,7 @@ class CompanyExport implements ShouldQueue
|
|||||||
$project = $this->transformBasicEntities($project);
|
$project = $this->transformBasicEntities($project);
|
||||||
$project = $this->transformArrayOfKeys($project, ['client_id']);
|
$project = $this->transformArrayOfKeys($project, ['client_id']);
|
||||||
|
|
||||||
return $project;
|
return $project->makeVisible(['id']);
|
||||||
|
|
||||||
})->all();
|
})->all();
|
||||||
|
|
||||||
@ -321,7 +321,7 @@ class CompanyExport implements ShouldQueue
|
|||||||
$quote = $this->transformBasicEntities($quote);
|
$quote = $this->transformBasicEntities($quote);
|
||||||
$quote = $this->transformArrayOfKeys($quote, ['invoice_id','recurring_id','client_id', 'vendor_id', 'project_id', 'design_id', 'subscription_id']);
|
$quote = $this->transformArrayOfKeys($quote, ['invoice_id','recurring_id','client_id', 'vendor_id', 'project_id', 'design_id', 'subscription_id']);
|
||||||
|
|
||||||
return $quote;
|
return $quote->makeVisible(['id']);
|
||||||
|
|
||||||
})->all();
|
})->all();
|
||||||
|
|
||||||
@ -339,7 +339,8 @@ class CompanyExport implements ShouldQueue
|
|||||||
|
|
||||||
$ri = $this->transformBasicEntities($ri);
|
$ri = $this->transformBasicEntities($ri);
|
||||||
$ri = $this->transformArrayOfKeys($ri, ['client_id', 'vendor_id', 'project_id', 'design_id', 'subscription_id']);
|
$ri = $this->transformArrayOfKeys($ri, ['client_id', 'vendor_id', 'project_id', 'design_id', 'subscription_id']);
|
||||||
return $ri;
|
|
||||||
|
return $ri->makeVisible(['id']);
|
||||||
|
|
||||||
})->all();
|
})->all();
|
||||||
|
|
||||||
@ -357,7 +358,13 @@ class CompanyExport implements ShouldQueue
|
|||||||
$subscription = $this->transformBasicEntities($subscription);
|
$subscription = $this->transformBasicEntities($subscription);
|
||||||
$subscription->group_id = $this->encodePrimaryKey($subscription->group_id);
|
$subscription->group_id = $this->encodePrimaryKey($subscription->group_id);
|
||||||
|
|
||||||
return $subscription;
|
return $subscription->makeVisible([ 'id',
|
||||||
|
'user_id',
|
||||||
|
'assigned_user_id',
|
||||||
|
'company_id',
|
||||||
|
'product_ids',
|
||||||
|
'recurring_product_ids',
|
||||||
|
'group_id']);
|
||||||
|
|
||||||
})->all();
|
})->all();
|
||||||
|
|
||||||
@ -376,7 +383,7 @@ class CompanyExport implements ShouldQueue
|
|||||||
$task = $this->transformBasicEntities($task);
|
$task = $this->transformBasicEntities($task);
|
||||||
$task = $this->transformArrayOfKeys($task, ['client_id', 'invoice_id', 'project_id', 'status_id']);
|
$task = $this->transformArrayOfKeys($task, ['client_id', 'invoice_id', 'project_id', 'status_id']);
|
||||||
|
|
||||||
return $task;
|
return $task->makeVisible(['id']);
|
||||||
|
|
||||||
})->all();
|
})->all();
|
||||||
|
|
||||||
@ -401,7 +408,7 @@ class CompanyExport implements ShouldQueue
|
|||||||
|
|
||||||
$this->export_data['vendors'] = $this->company->vendors->map(function ($vendor){
|
$this->export_data['vendors'] = $this->company->vendors->map(function ($vendor){
|
||||||
|
|
||||||
return $this->transformBasicEntities($vendor);
|
return $this->transformBasicEntities($vendor)->makeVisible(['id']);
|
||||||
|
|
||||||
})->all();
|
})->all();
|
||||||
|
|
||||||
@ -411,7 +418,7 @@ class CompanyExport implements ShouldQueue
|
|||||||
$vendor = $this->transformBasicEntities($vendor);
|
$vendor = $this->transformBasicEntities($vendor);
|
||||||
$vendor->vendor_id = $this->encodePrimaryKey($vendor->vendor_id);
|
$vendor->vendor_id = $this->encodePrimaryKey($vendor->vendor_id);
|
||||||
|
|
||||||
return $vendor;
|
return $vendor->makeVisible(['id']);
|
||||||
|
|
||||||
})->all();
|
})->all();
|
||||||
|
|
||||||
|
@ -70,10 +70,11 @@ class CompanyImport implements ShouldQueue
|
|||||||
// 'clients',
|
// 'clients',
|
||||||
// 'client_contacts',
|
// 'client_contacts',
|
||||||
// 'products',
|
// 'products',
|
||||||
// 'company_gateways',
|
|
||||||
// 'client_gateway_tokens',
|
|
||||||
// 'vendors',
|
// 'vendors',
|
||||||
// 'projects',
|
// 'projects',
|
||||||
|
// 'company_gateways',
|
||||||
|
// 'client_gateway_tokens',
|
||||||
|
// 'group_settings',
|
||||||
// 'credits',
|
// 'credits',
|
||||||
// 'invoices',
|
// 'invoices',
|
||||||
// 'recurring_invoices',
|
// 'recurring_invoices',
|
||||||
|
@ -25,7 +25,7 @@ use Illuminate\Support\Facades\Queue;
|
|||||||
class SystemHealth
|
class SystemHealth
|
||||||
{
|
{
|
||||||
private static $extensions = [
|
private static $extensions = [
|
||||||
'mysqli',
|
// 'mysqli',
|
||||||
'gd',
|
'gd',
|
||||||
'curl',
|
'curl',
|
||||||
'zip',
|
'zip',
|
||||||
@ -34,7 +34,7 @@ class SystemHealth
|
|||||||
'mbstring',
|
'mbstring',
|
||||||
'xml',
|
'xml',
|
||||||
'bcmath',
|
'bcmath',
|
||||||
'mysqlnd',
|
// 'mysqlnd',
|
||||||
//'intl', //todo double check whether we need this for email dns validation
|
//'intl', //todo double check whether we need this for email dns validation
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -14,21 +14,27 @@ use App\Jobs\Import\CSVImport;
|
|||||||
use App\Models\Account;
|
use App\Models\Account;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\ClientContact;
|
use App\Models\ClientContact;
|
||||||
|
use App\Models\ClientGatewayToken;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
|
use App\Models\CompanyGateway;
|
||||||
use App\Models\CompanyToken;
|
use App\Models\CompanyToken;
|
||||||
use App\Models\CompanyUser;
|
use App\Models\CompanyUser;
|
||||||
use App\Models\Expense;
|
use App\Models\Expense;
|
||||||
use App\Models\ExpenseCategory;
|
use App\Models\ExpenseCategory;
|
||||||
|
use App\Models\GroupSetting;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use App\Models\PaymentTerm;
|
use App\Models\PaymentTerm;
|
||||||
use App\Models\Product;
|
use App\Models\Product;
|
||||||
use App\Models\Vendor;
|
use App\Models\Project;
|
||||||
use App\Models\VendorContact;
|
use App\Models\RecurringInvoice;
|
||||||
|
use App\Models\RecurringInvoiceInvitation;
|
||||||
|
use App\Models\Subscription;
|
||||||
use App\Models\TaskStatus;
|
use App\Models\TaskStatus;
|
||||||
use App\Models\TaxRate;
|
use App\Models\TaxRate;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Models\Vendor;
|
use App\Models\Vendor;
|
||||||
|
use App\Models\VendorContact;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
use Illuminate\Routing\Middleware\ThrottleRequests;
|
use Illuminate\Routing\Middleware\ThrottleRequests;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
@ -416,73 +422,198 @@ class ImportCompanyTest extends TestCase
|
|||||||
$this->assertEquals(1, ClientContact::count());
|
$this->assertEquals(1, ClientContact::count());
|
||||||
/***************************** Client Contacts *****************************/
|
/***************************** Client Contacts *****************************/
|
||||||
|
|
||||||
/* Generic */
|
|
||||||
|
|
||||||
|
|
||||||
/* Generic */
|
|
||||||
|
|
||||||
//vendors!
|
//vendors!
|
||||||
|
/* Generic */
|
||||||
|
$this->assertEquals(1, count($this->backup_json_object->vendors));
|
||||||
|
|
||||||
|
$this->genericImport(Vendor::class,
|
||||||
|
['user_id', 'assigned_user_id', 'company_id', 'id', 'hashed_id'],
|
||||||
|
[['users' => 'user_id'], ['users' =>'assigned_user_id']],
|
||||||
|
'vendors',
|
||||||
|
'number');
|
||||||
|
|
||||||
|
$this->assertEquals(1, Vendor::count());
|
||||||
|
|
||||||
|
/* Generic */
|
||||||
|
|
||||||
|
$this->assertEquals(1, count($this->backup_json_object->projects));
|
||||||
|
//$class, $unset, $transforms, $object_property, $match_key
|
||||||
|
$this->genericImport(Project::class,
|
||||||
|
['user_id', 'assigned_user_id', 'company_id', 'id', 'hashed_id','client_id'],
|
||||||
|
[['users' => 'user_id'], ['users' =>'assigned_user_id'], ['clients' => 'client_id']],
|
||||||
|
'projects',
|
||||||
|
'number');
|
||||||
|
|
||||||
|
$this->assertEquals(1, Project::count());
|
||||||
|
|
||||||
//projects!
|
//projects!
|
||||||
|
|
||||||
/***************************** Products *****************************/
|
//products!
|
||||||
// Product::unguard();
|
|
||||||
|
|
||||||
// $this->assertEquals(1, count($this->backup_json_object->products));
|
$this->assertEquals(1, count($this->backup_json_object->products));
|
||||||
|
|
||||||
// foreach($this->backup_json_object->products as $obj)
|
$this->genericNewClassImport(Product::class,
|
||||||
// {
|
['user_id', 'company_id', 'hashed_id', 'id'],
|
||||||
|
[['users' => 'user_id'], ['users' =>'assigned_user_id'], ['vendors' => 'vendor_id'], ['projects' => 'project_id']],
|
||||||
|
'products'
|
||||||
|
);
|
||||||
|
$this->assertEquals(1, Product::count());
|
||||||
|
|
||||||
// $user_id = $this->transformId('users', $obj->user_id);
|
//company gateways
|
||||||
// $assigned_user_id = $this->transformId('users', $obj->assigned_user_id);
|
|
||||||
// $vendor_id = $this->transformId('vendors', $obj->vendor_id);
|
|
||||||
// $project_id = $this->transformId('projects', $obj->project_id);
|
|
||||||
|
|
||||||
// $obj_array = (array)$obj;
|
$this->assertEquals(1, count($this->backup_json_object->company_gateways));
|
||||||
// unset($obj_array['user_id']);
|
|
||||||
// unset($obj_array['company_id']);
|
$this->genericNewClassImport(CompanyGateway::class,
|
||||||
// unset($obj_array['account_id']);
|
['user_id', 'company_id', 'hashed_id', 'id'],
|
||||||
// unset($obj_array['hashed_id']);
|
[['users' => 'user_id']],
|
||||||
// unset($obj_array['id']);
|
'company_gateways'
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(1, CompanyGateway::count());
|
||||||
|
|
||||||
|
//company gateways
|
||||||
|
|
||||||
|
|
||||||
// $new_obj = new Product();
|
//client gateway tokens
|
||||||
// $new_obj->company_id = $this->company->id;
|
|
||||||
// $new_obj->user_id = $user_id;
|
|
||||||
// $new_obj->assigned_user_id = $assigned_user_id;
|
|
||||||
// $new_obj->vendor_id = $vendor_id;
|
|
||||||
// $new_obj->project_id = $project_id;
|
|
||||||
// $new_obj->fill($obj_array);
|
|
||||||
|
|
||||||
// $new_obj->save(['timestamps' => false]);
|
$this->genericNewClassImport(ClientGatewayToken::class,
|
||||||
|
['company_id', 'id', 'hashed_id','client_id'],
|
||||||
|
[['clients' => 'client_id']],
|
||||||
|
'client_gateway_tokens');
|
||||||
|
|
||||||
// $this->ids['products']["{$obj->hashed_id}"] = $new_obj->id;
|
//client gateway tokens
|
||||||
|
|
||||||
// }
|
//Group Settings
|
||||||
|
$this->genericImport(GroupSetting::class,
|
||||||
|
['user_id', 'company_id', 'id', 'hashed_id',],
|
||||||
|
[['users' => 'user_id']],
|
||||||
|
'group_settings',
|
||||||
|
'name');
|
||||||
|
//Group Settings
|
||||||
|
|
||||||
// Product::reguard();
|
//Subscriptions
|
||||||
|
$this->assertEquals(1, count($this->backup_json_object->subscriptions));
|
||||||
|
|
||||||
// $this->assertEquals(1, Product::count());
|
$this->genericImport(Subscription::class,
|
||||||
/***************************** Products *****************************/
|
['user_id', 'assigned_user_id', 'company_id', 'id', 'hashed_id',],
|
||||||
|
[['group_settings' => 'group_id'], ['users' => 'user_id'], ['users' => 'assigned_user_id']],
|
||||||
|
'subscriptions',
|
||||||
|
'name');
|
||||||
|
|
||||||
|
$this->assertEquals(1, Subscription::count());
|
||||||
|
|
||||||
|
//Subscriptions
|
||||||
|
|
||||||
|
// Recurring Invoices
|
||||||
|
|
||||||
|
$this->assertEquals(2, count($this->backup_json_object->recurring_invoices));
|
||||||
|
|
||||||
|
$this->genericImport(RecurringInvoice::class,
|
||||||
|
['user_id', 'assigned_user_id', 'company_id', 'id', 'hashed_id', 'client_id','subscription_id','project_id','vendor_id','status'],
|
||||||
|
[
|
||||||
|
['subscriptions' => 'subscription_id'],
|
||||||
|
['users' => 'user_id'],
|
||||||
|
['users' => 'assigned_user_id'],
|
||||||
|
['clients' => 'client_id'],
|
||||||
|
['projects' => 'project_id'],
|
||||||
|
['vendors' => 'vendor_id'],
|
||||||
|
['clients' => 'client_id'],
|
||||||
|
],
|
||||||
|
'recurring_invoices',
|
||||||
|
'number');
|
||||||
|
|
||||||
|
$this->assertEquals(2, RecurringInvoice::count());
|
||||||
|
|
||||||
|
// Recurring Invoices
|
||||||
|
|
||||||
|
|
||||||
|
// Recurring Invoice Invitations
|
||||||
|
|
||||||
|
$this->assertEquals(2, count($this->backup_json_object->recurring_invoice_invitations));
|
||||||
|
nlog($this->backup_json_object->recurring_invoice_invitations);
|
||||||
|
$this->genericImport(RecurringInvoiceInvitation::class,
|
||||||
|
['user_id', 'client_contact_id', 'company_id', 'id', 'hashed_id'],
|
||||||
|
[
|
||||||
|
['users' => 'user_id'],
|
||||||
|
['recurring_invoices' => 'recurring_invoice_id'],
|
||||||
|
['client_contacts' => 'client_contact_id'],
|
||||||
|
],
|
||||||
|
'recurring_invoice_invitations',
|
||||||
|
'key');
|
||||||
|
|
||||||
|
$this->assertEquals(2, RecurringInvoiceInvitation::count());
|
||||||
|
|
||||||
|
// Recurring Invoice Invitations
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function genericImport($class, $unset, $transform, $object_property, $match_key)
|
private function genericNewClassImport($class, $unset, $transforms, $object_property)
|
||||||
{
|
{
|
||||||
|
|
||||||
$class::unguard();
|
$class::unguard();
|
||||||
|
|
||||||
|
|
||||||
foreach($this->backup_json_object->{$object_property} as $obj)
|
foreach($this->backup_json_object->{$object_property} as $obj)
|
||||||
{
|
{
|
||||||
|
/* Remove unwanted keys*/
|
||||||
$obj_array = (array)$obj;
|
$obj_array = (array)$obj;
|
||||||
foreach($unset as $un){
|
foreach($unset as $un){
|
||||||
unset($obj_array[$un]);
|
unset($obj_array[$un]);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($trans as $key => $value)
|
/* Transform old keys to new keys */
|
||||||
|
foreach($transforms as $transform)
|
||||||
{
|
{
|
||||||
$obj_array["{$value}"] = $this->transformId($object_property, $obj->{$value});
|
foreach($transform as $key => $value)
|
||||||
|
{
|
||||||
|
$obj_array["{$value}"] = $this->transformId($key, $obj->{$value});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($class instanceof CompanyGateway) {
|
||||||
|
$obj_array['config'] = encrypt($obj_array['config']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$new_obj = new $class();
|
||||||
|
$new_obj->company_id = $this->company->id;
|
||||||
|
$new_obj->fill($obj_array);
|
||||||
|
|
||||||
|
$new_obj->save(['timestamps' => false]);
|
||||||
|
|
||||||
|
$this->ids["{$object_property}"]["{$obj->hashed_id}"] = $new_obj->id;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$class::reguard();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function genericImport($class, $unset, $transforms, $object_property, $match_key)
|
||||||
|
{
|
||||||
|
|
||||||
|
$class::unguard();
|
||||||
|
|
||||||
|
foreach($this->backup_json_object->{$object_property} as $obj)
|
||||||
|
{
|
||||||
|
/* Remove unwanted keys*/
|
||||||
|
$obj_array = (array)$obj;
|
||||||
|
foreach($unset as $un){
|
||||||
|
unset($obj_array[$un]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Transform old keys to new keys */
|
||||||
|
foreach($transforms as $transform)
|
||||||
|
{
|
||||||
|
foreach($transform as $key => $value)
|
||||||
|
{
|
||||||
|
$obj_array["{$value}"] = $this->transformId($key, $obj->{$value});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* New to convert product ids from old hashes to new hashes*/
|
||||||
|
if($class instanceof Subscription){
|
||||||
|
$obj_array['product_ids'] = $this->recordProductIds($obj_array['product_ids']);
|
||||||
|
$obj_array['recurring_product_ids'] = $this->recordProductIds($obj_array['recurring_product_ids']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$new_obj = $class::firstOrNew(
|
$new_obj = $class::firstOrNew(
|
||||||
@ -498,7 +629,21 @@ class ImportCompanyTest extends TestCase
|
|||||||
|
|
||||||
$class::reguard();
|
$class::reguard();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function recordProductIds($ids)
|
||||||
|
{
|
||||||
|
|
||||||
|
$id_array = explode(",", $ids);
|
||||||
|
|
||||||
|
$tmp_arr = [];
|
||||||
|
|
||||||
|
foreach($id_array as $id) {
|
||||||
|
|
||||||
|
$tmp_arr[] = $this->encodePrimaryKey($this->transformId('products', $id));
|
||||||
|
}
|
||||||
|
|
||||||
|
return implode(",", $tmp_arr);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function transformId(string $resource, ?string $old): ?int
|
private function transformId(string $resource, ?string $old): ?int
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user