option('force')) { // Only sync locations that are missing division data $query->whereNotNull('city_id')->whereNull('division_id'); } $locations = $query->get(); $syncedCount = 0; $totalSynced = []; $this->info("Processing {$locations->count()} locations..."); foreach ($locations as $location) { try { $synced = $location->syncAllLocationData(); if (!empty($synced)) { $syncedCount++; $totalSynced = array_merge($totalSynced, $synced); $this->line("Location ID {$location->id}: " . implode(', ', $synced)); } } catch (\Exception $e) { $this->error("Failed to sync location ID {$location->id}: " . $e->getMessage()); } } $syncStats = array_count_values($totalSynced); $this->info("\nCompleted syncing {$syncedCount} locations:"); foreach ($syncStats as $type => $count) { $this->info(" - {$count} locations synced {$type}"); } } }