tenant = $this->option("tenant"); setup_db_connection(); config(['database.connections.mysql-tenant.database' => config('json.prefix_db') . "_ente{$this->tenant}"]); DB::purge('mysql-tenant'); $tenant = Tenant::where("codice", $this->tenant)->first(); $collections = Conservazione::where("stato", "<", 20) ->orWhere("stato", 90); if($collections->count() > 0) { foreach($collections->cursor() as $collection) { if($collection->archivio == "N" || $collection->archivio == "W") { $this->info("Processing #{$collection->codice}"); $collection->stato = 20; $collection->save(); if($collection->items()->count() < 1) { $this->line("Getting files."); $full_archive = true; $proceed_with_next_job = false; GetFilesJob::dispatchSync($tenant->codice, $collection->codice, $full_archive, $proceed_with_next_job); } $this->line("Archiving files."); $collection->stato = 5; $collection->save(); MakeZipArchiveJob::dispatchSync($tenant->codice, $collection->codice); } } } } }