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') $file_location = $request->file('files')
->storeAs( ->storeAs(
'migrations', 'migrations',
$request->file('files')->getClientOriginalName() $request->file('files')->getClientOriginalName(),
config('filesystems.default'),
); );
if(Ninja::isHosted()) if(Ninja::isHosted())

View File

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

View File

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