mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04: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);
|
set_time_limit(0);
|
||||||
|
|
||||||
$this->export_data['app_version'] = config('ninja.app_version');
|
$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){
|
$this->export_data['activities'] = $this->company->all_activities->map(function ($activity){
|
||||||
|
|
||||||
@ -167,6 +168,7 @@ class CompanyExport implements ShouldQueue
|
|||||||
|
|
||||||
|
|
||||||
$this->export_data['company'] = $this->company->toArray();
|
$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){
|
$this->export_data['company_gateways'] = $this->company->company_gateways()->withTrashed()->cursor()->map(function ($company_gateway){
|
||||||
|
|
||||||
|
@ -1075,7 +1075,6 @@ class CompanyImport implements ShouldQueue
|
|||||||
private function import_documents()
|
private function import_documents()
|
||||||
{
|
{
|
||||||
|
|
||||||
// foreach($this->backup_file->documents as $document)
|
|
||||||
foreach((object)$this->getObject("documents") as $document)
|
foreach((object)$this->getObject("documents") as $document)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -1105,6 +1104,29 @@ class CompanyImport implements ShouldQueue
|
|||||||
|
|
||||||
$new_document->save(['timestamps' => false]);
|
$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;
|
return $this;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user