mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Attempt to import documents into new company
This commit is contained in:
parent
118ddc87a1
commit
a6dec224d2
@ -77,6 +77,7 @@ class CompanyExport implements ShouldQueue
|
||||
set_time_limit(0);
|
||||
|
||||
$this->export_data['app_version'] = config('ninja.app_version');
|
||||
$this->export_data['storage_url'] = Storage::url('');
|
||||
|
||||
$this->export_data['activities'] = $this->company->all_activities->map(function ($activity){
|
||||
|
||||
@ -167,7 +168,8 @@ class CompanyExport implements ShouldQueue
|
||||
|
||||
|
||||
$this->export_data['company'] = $this->company->toArray();
|
||||
|
||||
$this->export_data['company']['company_key'] = $this->createHash();
|
||||
|
||||
$this->export_data['company_gateways'] = $this->company->company_gateways()->withTrashed()->cursor()->map(function ($company_gateway){
|
||||
|
||||
$company_gateway = $this->transformArrayOfKeys($company_gateway, ['company_id', 'user_id']);
|
||||
|
@ -1075,7 +1075,6 @@ class CompanyImport implements ShouldQueue
|
||||
private function import_documents()
|
||||
{
|
||||
|
||||
// foreach($this->backup_file->documents as $document)
|
||||
foreach((object)$this->getObject("documents") as $document)
|
||||
{
|
||||
|
||||
@ -1105,6 +1104,29 @@ class CompanyImport implements ShouldQueue
|
||||
|
||||
$new_document->save(['timestamps' => false]);
|
||||
|
||||
|
||||
$storage_url = (object)$this->getObject('storage_url', true);
|
||||
|
||||
if(!Storage::exists($new_document->url)){
|
||||
|
||||
$url = $storage_url . $new_document->url;
|
||||
|
||||
$file = @file_get_contents($url);
|
||||
|
||||
if($file)
|
||||
{
|
||||
try{
|
||||
Storage::disk(config('filesystems.default'))->put($new_document->url, $file);
|
||||
}
|
||||
catch(\Exception $e)
|
||||
{
|
||||
nlog($e->getMessage());
|
||||
nlog("I could not upload {$new_document->url}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
Loading…
Reference in New Issue
Block a user