1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-12 22:22:32 +01:00

Fixes for uploading and downloading company imports

This commit is contained in:
David Bomba 2021-08-30 15:35:37 +10:00
parent 003f326f8d
commit ae88b61e8d
3 changed files with 15 additions and 5 deletions

View File

@ -66,7 +66,8 @@ class ImportJsonController extends BaseController
$file_location = $request->file('files')
->storeAs(
'migrations',
$request->file('files')->getClientOriginalName()
$request->file('files')->getClientOriginalName(),
config('filesystems.default'),
);
if(Ninja::isHosted())

View File

@ -224,7 +224,7 @@ class CompanyImport implements ShouldQueue
// if(mime_content_type(Storage::path($this->file_location)) == 'text/plain')
// return Storage::path($this->file_location);
$path = TempFile::filePath(Storage::get($this->file_location), basename($this->file_location));
$path = TempFile::filePath(Storage::disk(config('filesystems.default'))->get($this->file_location), basename($this->file_location));
$zip = new ZipArchive();
$archive = $zip->open($path);
@ -235,7 +235,7 @@ class CompanyImport implements ShouldQueue
$zip->close();
$file_location = "{$file_path}/backup.json";
if (! file_exists($file_location))
if (! file_exists($file_path))
throw new NonExistingMigrationFile('Backup file does not exist, or is corrupted.');
return $file_location;
@ -568,7 +568,7 @@ class CompanyImport implements ShouldQueue
{
$this->genericImport(GroupSetting::class,
['user_id', 'company_id', 'id', 'hashed_id',],
['user_id', 'company_id', 'id', 'hashed_id'],
[['users' => 'user_id']],
'group_settings',
'name');
@ -580,7 +580,7 @@ class CompanyImport implements ShouldQueue
{
$this->genericImport(Subscription::class,
['user_id', 'assigned_user_id', 'company_id', 'id', 'hashed_id',],
['user_id', 'assigned_user_id', 'company_id', 'id', 'hashed_id'],
[['group_settings' => 'group_id'], ['users' => 'user_id'], ['users' => 'assigned_user_id']],
'subscriptions',
'name');

View File

@ -34,6 +34,15 @@ class GroupSetting extends StaticModel
'settings',
];
protected $appends = [
'hashed_id',
];
public function getHashedIdAttribute()
{
return $this->encodePrimaryKey($this->id);
}
protected $touches = [];
public function company()