filepath = $filepath; $this->user = $user; $this->company = $company; } /** * Execute the job. * * @return void */ public function handle() { MultiDB::setDb($this->company->db); $zip = new \ZipArchive(); $archive = $zip->open($this->filepath); $filename = pathinfo($this->filepath, PATHINFO_FILENAME); try { if ($archive) { $zip->extractTo(storage_path("migrations/{$filename}")); $zip->close(); $migration_file = storage_path("migrations/$filename/migration.json"); $handle = fopen($migration_file, "r"); $migration_file = fread($handle, filesize($migration_file)); fclose($handle); $data = json_decode($migration_file,1); Import::dispatchNow($data, $this->company, $this->user); } else { throw new ProcessingMigrationArchiveFailed(); } } catch (ProcessingMigrationArchiveFailed $e) { // TODO: Break the code, stop the migration.. send an e-mail. } // Rest of the migration.. } }