company = $company; $this->file_path = $file_path; $this->options = $options; } public function handle() { MultiDB::setDb($this->company->db); $this->company =Company::where('company_key', $this->company->company_key)->firstOrFail(); $this->unzipFile() ->preFlightChecks(); } //check if this is a complete company import OR if it is selective /* Company and settings only Data */ private function preFlightChecks() { //check the file version and perform any necessary adjustments to the file in order to proceed - needed when we change schema // $app_version = $this->backup_file->app_version; nlog($app_version); return $this; } private function unzipFile() { $zip = new ZipArchive(); $archive = $zip->open(public_path("storage/backups/{$this->file_path}")); $filename = pathinfo($this->filepath, PATHINFO_FILENAME); $zip->extractTo(public_path("storage/backups/{$filename}")); $zip->close(); $file_location = public_path("storage/backups/$filename/backup.json"); if (! file_exists($file_location)) { throw new NonExistingMigrationFile('Backup file does not exist, or it is corrupted.'); } $this->backup_file = json_decode(file_get_contents($file_location)); return $this; } private function importCompany() { //$this->import_company = .. return $this; } private function importData() { // $this->import_company = Company::where('company_key', $this->company->company_key)->firstOrFail(); return $this; } }